-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
143 lines (120 loc) · 3.78 KB
/
flake.nix
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
{
description = "Check the forecast for today's Nix builds";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs =
{
self,
nixpkgs,
}:
let
inherit (nixpkgs) lib;
# We want to generate outputs for as many systems as possible,
# even if we don't officially support or test for them
allSystems = lib.systems.flakeExposed;
# These are the systems we do officially support and test, though
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forAllSystems = lib.genAttrs allSystems;
nixpkgsFor = nixpkgs.legacyPackages;
in
{
checks = forAllSystems (
system:
let
pkgs = nixpkgsFor.${system};
packages = self.packages.${system};
mkCheck =
name: deps: script:
pkgs.runCommand name { nativeBuildInputs = deps; } ''
${script}
touch $out
'';
in
lib.optionalAttrs (lib.elem system supportedSystems) {
clippy = packages.nix-forecast.overrideAttrs {
pname = "check-clippy";
nativeBuildInputs = [
pkgs.cargo
pkgs.clippy
pkgs.clippy-sarif
pkgs.rustPlatform.cargoSetupHook
pkgs.rustc
pkgs.sarif-fmt
];
buildPhase = ''
runHook preBuild
cargo clippy \
--all-features \
--all-targets \
--tests \
--message-format=json \
| clippy-sarif | tee $out | sarif-fmt
runHook postBuild
'';
dontInstall = true;
doCheck = false;
doInstallCheck = false;
dontFixup = true;
passthru = { };
meta = { };
};
rustfmt = mkCheck "check-cargo-fmt" [
pkgs.cargo
pkgs.rustfmt
] "cd ${self} && cargo fmt -- --check";
actionlint = mkCheck "check-actionlint" [
pkgs.actionlint
] "actionlint ${self}/.github/workflows/*";
deadnix = mkCheck "check-deadnix" [ pkgs.deadnix ] "deadnix --fail ${self}";
nixfmt = mkCheck "check-nixfmt" [ pkgs.nixfmt-rfc-style ] "nixfmt --check ${self}";
statix = mkCheck "check-statix" [ pkgs.statix ] "statix check ${self}";
}
);
devShells = forAllSystems (
system:
let
pkgs = nixpkgsFor.${system};
in
lib.optionalAttrs (lib.elem system supportedSystems) {
default = pkgs.mkShell {
packages = [
# Rust tools
pkgs.clippy
pkgs.rust-analyzer
pkgs.rustfmt
# Nix tools
self.formatter.${system}
pkgs.nil
pkgs.statix
];
env = {
RUST_SRC_PATH = toString pkgs.rustPlatform.rustLibSrc;
};
inputsFrom = [ self.packages.${system}.nix-forecast ];
};
}
);
formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style);
legacyPackages = forAllSystems (system: {
nix-forecast-debug = self.packages.${system}.nix-forecast.overrideAttrs (
finalAttrs: _: {
cargoBuildType = "debug";
cargoCheckType = finalAttrs.cargoBuildType;
}
);
});
packages = forAllSystems (
system:
let
pkgs = nixpkgsFor.${system};
pkgs' = import ./default.nix { inherit pkgs; };
in
pkgs' // { default = pkgs'.nix-forecast; }
);
overlays.default = final: prev: import ./overlay.nix final prev;
};
}