-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathflake.nix
More file actions
165 lines (145 loc) · 4.97 KB
/
Copy pathflake.nix
File metadata and controls
165 lines (145 loc) · 4.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
{
description = "stdbr";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
devshell = {
url = "github:numtide/devshell";
inputs.nixpkgs.follows = "nixpkgs";
};
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
imports = [
inputs.devshell.flakeModule
inputs.treefmt-nix.flakeModule
];
perSystem = { system, lib, ... }:
let
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [ (import inputs.rust-overlay) ];
};
rustToolchain = (pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml).override {
extensions = [ "llvm-tools-preview" ];
};
fuzzToolchain = pkgs.rust-bin.nightly.latest.minimal;
msrvToolchain = pkgs.rust-bin.stable."1.85.0".minimal;
semverToolchain = pkgs.rust-bin.stable."1.91.0".minimal;
nativeToolchain = pkgs.symlinkJoin {
name = "stdbr-native-toolchain";
paths = [ pkgs.gcc pkgs.binutils ];
};
in
{
_module.args.pkgs = pkgs;
treefmt = {
projectRootFile = "flake.nix";
programs = {
rustfmt.enable = true;
nixpkgs-fmt.enable = true;
buildifier.enable = true;
};
};
checks.quality-static = pkgs.runCommand "stdbr-quality-static"
{
nativeBuildInputs = with pkgs; [ actionlint shellcheck ];
} ''
shellcheck ${./tools/quality/quality.sh}
actionlint \
${./.github/workflows/ci.yml} \
${./.github/workflows/ibge-sync.yml} \
${./.github/workflows/publish-test.yml} \
${./.github/workflows/release.yml}
touch $out
'';
devshells.default = {
name = "stdbr";
packages = with pkgs; [
rustToolchain
bazel_7
bazel-buildtools
nativeToolchain
pkg-config
openssl
cacert
git
jdk
python3
maturin
wasm-pack
nodejs
cargo-audit
cargo-fuzz
cargo-llvm-cov
cargo-semver-checks
actionlint
shellcheck
] ++ lib.optionals pkgs.stdenv.isDarwin [
pkgs.libiconv
pkgs.darwin.apple_sdk.frameworks.Security
pkgs.darwin.apple_sdk.frameworks.SystemConfiguration
];
env = [
{
name = "PATH";
prefix = "${nativeToolchain}/bin";
}
{ name = "CC"; value = "${nativeToolchain}/bin/gcc"; }
{ name = "AR"; value = "${nativeToolchain}/bin/ar"; }
{ name = "CBINDGEN"; value = lib.getExe pkgs.rust-cbindgen; }
{ name = "FUZZ_CARGO"; value = "${fuzzToolchain}/bin/cargo"; }
{ name = "FUZZ_RUSTC"; value = "${fuzzToolchain}/bin/rustc"; }
{ name = "MSRV_CARGO"; value = "${msrvToolchain}/bin/cargo"; }
{ name = "MSRV_RUSTC"; value = "${msrvToolchain}/bin/rustc"; }
{ name = "SEMVER_TOOLCHAIN_BIN"; value = "${semverToolchain}/bin"; }
{ name = "RUST_SRC_PATH"; value = "${rustToolchain}/lib/rustlib/src/rust/library"; }
];
commands = [
{
name = "build";
command = "bazel build //...";
help = "Build all targets";
category = "bazel";
}
{
name = "check";
command = "bazel test //:all_tests";
help = "Run all tests";
category = "bazel";
}
{
name = "fmt";
command = "nix fmt";
help = "Format all files (rustfmt + nixpkgs-fmt + buildifier)";
category = "dev";
}
{
name = "quality";
command = ''"$PRJ_ROOT/tools/quality/quality.sh" all "$@"'';
help = "Run all local quality gates with bounded resources";
category = "dev";
}
{
name = "clean";
command = "bazel clean --expunge";
help = "Clean bazel cache";
category = "bazel";
}
];
};
};
};
}