-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
flake.nix
199 lines (176 loc) · 5.35 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
{
description = "healthchecks-rs monorepo";
inputs.nixpkgs.url = "github:msfjarvis/nixpkgs/nixpkgs-unstable";
inputs.systems.url = "github:msfjarvis/flake-systems";
inputs.advisory-db.url = "github:rustsec/advisory-db";
inputs.advisory-db.flake = false;
inputs.crane.url = "github:ipetkov/crane";
inputs.devshell.url = "github:numtide/devshell";
inputs.devshell.inputs.nixpkgs.follows = "nixpkgs";
inputs.fenix.url = "github:nix-community/fenix/staging";
inputs.fenix.inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.flake-utils.inputs.systems.follows = "systems";
inputs.flake-compat.url = "github:nix-community/flake-compat";
inputs.flake-compat.flake = false;
# Keep in sync with healthchecks/Cargo.toml
inputs.rust-msrv.url = "https://static.rust-lang.org/dist/channel-rust-1.72.0.toml";
inputs.rust-msrv.flake = false;
outputs =
{
nixpkgs,
devshell,
fenix,
crane,
flake-utils,
advisory-db,
rust-msrv,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ devshell.overlays.default ];
};
rustStable = (import fenix { inherit pkgs; }).fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-s1RPtyvDGJaX/BisLT+ifVfuhDT1nZkZ1NcK8sbwELM=";
};
rustMsrv = (fenix.packages.${system}.fromManifestFile rust-msrv).minimalToolchain;
craneLib = (crane.mkLib pkgs).overrideToolchain rustStable;
markdownFilter = path: _type: builtins.match ".*md$" path != null;
markdownOrCargo = path: type: (markdownFilter path type) || (craneLib.filterCargoSources path type);
commonArgs = {
src = pkgs.lib.cleanSourceWith {
src = craneLib.path ./.;
filter = markdownOrCargo;
};
buildInputs = [ ];
nativeBuildInputs = [ ];
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
};
hcctlName = craneLib.crateNameFromCargoToml {
cargoToml = ./hcctl/Cargo.toml;
};
healthchecksName = craneLib.crateNameFromCargoToml {
cargoToml = ./healthchecks/Cargo.toml;
};
monitorName = craneLib.crateNameFromCargoToml {
cargoToml = ./monitor/Cargo.toml;
};
workspaceName = {
version = "1.0.0";
pname = "healthchecks-rs";
};
audit = craneLib.cargoAudit (
commonArgs
// {
inherit advisory-db;
inherit (workspaceName) pname version;
}
);
cargoArtifacts = craneLib.buildDepsOnly (
commonArgs
// {
inherit (workspaceName) pname version;
}
);
fmt = craneLib.cargoFmt (
commonArgs
// {
inherit (workspaceName) pname version;
}
);
hcctl = craneLib.buildPackage (
commonArgs
// {
inherit (hcctlName) pname version;
inherit cargoArtifacts;
cargoExtraArgs = "-p hcctl";
doCheck = false;
}
);
monitor = craneLib.buildPackage (
commonArgs
// {
inherit (monitorName) pname version;
inherit cargoArtifacts;
cargoExtraArgs = "-p healthchecks-monitor";
doCheck = false;
}
);
workspace = craneLib.buildPackage (
commonArgs
// {
inherit (healthchecksName) pname version;
inherit cargoArtifacts;
doCheck = false;
}
);
workspace-clippy = craneLib.cargoClippy (
commonArgs
// {
inherit (healthchecksName) pname version;
inherit cargoArtifacts;
}
);
workspace-nextest = craneLib.cargoNextest (
commonArgs
// {
inherit (healthchecksName) pname version;
inherit cargoArtifacts;
partitions = 1;
partitionType = "count";
}
);
healthchecks-msrv = ((crane.mkLib pkgs).overrideToolchain rustMsrv).buildPackage (
commonArgs
// {
inherit (healthchecksName) version;
pname = "healthchecks-msrv";
cargoExtraArgs = "-p healthchecks";
doCheck = false;
}
);
in
{
checks = {
inherit
audit
fmt
workspace
workspace-clippy
healthchecks-msrv
workspace-nextest
;
};
packages = {
inherit hcctl monitor;
};
apps.hcctl = flake-utils.lib.mkApp { drv = hcctl; };
apps.monitor = flake-utils.lib.mkApp { drv = monitor; };
devShells.default = pkgs.devshell.mkShell {
bash = {
interactive = "";
};
env = [
{
name = "DEVSHELL_NO_MOTD";
value = 1;
}
];
packages = with pkgs; [
cargo-nextest
cargo-release
cargo-semver-checks
fenix.packages.${system}.rust-analyzer
nil
rustStable
stdenv.cc
];
};
}
);
}