Skip to content

Commit a8f29a1

Browse files
committed
Add more to flake checks
1 parent 5332924 commit a8f29a1

File tree

5 files changed

+85
-53
lines changed

5 files changed

+85
-53
lines changed

.github/workflows/push.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ jobs:
3030
purge-primary-key: never
3131

3232
- name: Check nix flake
33-
run: nix flake check
33+
run: nix -L flake check
3434

3535
- name: Build backend with nix
36-
run: nix build .#backend
36+
run: nix -L build .#backend
3737

3838
- name: Upload built nix package
3939
uses: actions/upload-artifact@v4

Cargo.lock

Lines changed: 0 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ anyhow = "1.0.98"
1111
base16ct = { version = "0.2.0", features = ["std"] }
1212
clap = { version = "4.5.41", features = ["derive", "env"] }
1313
env_logger = "0.11.8"
14-
itertools = "0.14.0"
1514
moka = { version = "0.12.10", features = ["future"] }
16-
prometheus-client = "0.23.1"
15+
# prometheus-client = "0.23.1"
1716
quick-xml = { version = "0.38.0", features = ["serde", "serialize"] }
1817
reqwest = { version = "0.12.22", default-features = false, features = ["charset", "http2", "system-proxy", "json", "rustls-tls"] }
1918
semver = "1.0.26"

flake.lock

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
inputs.nixpkgs.follows = "nixpkgs";
88
};
99
crane.url = "github:ipetkov/crane";
10+
advisory-db = {
11+
url = "github:rustsec/advisory-db";
12+
flake = false;
13+
};
1014
treefmt-nix = {
1115
url = "github:numtide/treefmt-nix";
1216
inputs.nixpkgs.follows = "nixpkgs";
@@ -20,6 +24,7 @@
2024
flake-utils,
2125
rust-overlay,
2226
crane,
27+
advisory-db,
2328
treefmt-nix,
2429
...
2530
}:
@@ -41,10 +46,13 @@
4146
buildInputs = with pkgs; [ openssl ];
4247
nativeBuildInputs = with pkgs; [ pkg-config ];
4348
};
49+
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
50+
commonArgsWithDeps = commonArgs // {
51+
inherit cargoArtifacts;
52+
};
4453
cranePackage = craneLib.buildPackage (
45-
commonArgs
54+
commonArgsWithDeps
4655
// {
47-
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
4856
meta = {
4957
mainProgram = "backend";
5058
license = lib.licenses.gpl3Plus;
@@ -61,14 +69,68 @@
6169
backend = cranePackage;
6270
};
6371
formatter = treefmtEval.config.build.wrapper;
64-
checks.formatting = treefmtEval.config.build.check self;
72+
checks = {
73+
formatting = treefmtEval.config.build.check self;
74+
clippy = craneLib.cargoClippy (
75+
commonArgsWithDeps // { cargoClippyExtraArgs = "--all-targets -- --deny warnings"; }
76+
);
77+
deny =
78+
let
79+
git = ''HOME="$GIT_HOME" git'';
80+
gitInit = ''
81+
${git} config --global init.defaultBranch "main"
82+
${git} config --global user.email "example@example.com"
83+
${git} config --global user.name "John Doe"
84+
${git} init
85+
${git} add -A
86+
${git} commit -m "init"
87+
'';
88+
in
89+
craneLib.cargoDeny (
90+
commonArgs
91+
// {
92+
cargoDenyChecks = "--disable-fetch all";
93+
nativeBuildInputs = [ pkgs.git ];
94+
configurePhase = ''
95+
runHook preConfigure
96+
97+
DB_PATH="$CARGO_HOME"/advisory-dbs/advisory-db-3157b0e258782691
98+
mkdir -p "$DB_PATH"
99+
100+
pushd "$DB_PATH"
101+
102+
ln -s ${advisory-db}/{*,.*} .
103+
GIT_HOME="$(mktemp -d)"
104+
${gitInit} # Cargo-deny complains if it isn't a real repo
105+
106+
popd
107+
108+
runHook postConfigure
109+
'';
110+
}
111+
);
112+
udeps = craneLib.mkCargoDerivation (
113+
commonArgsWithDeps
114+
// {
115+
nativeBuildInputs = [ pkgs.cargo-udeps ];
116+
pnameSuffix = "-udeps";
117+
buildPhaseCargoCommand = ''
118+
cargo --offline \
119+
udeps \
120+
--all-targets \
121+
--all-features
122+
'';
123+
}
124+
);
125+
};
65126
devShells.default = craneLib.devShell {
66127
# Add all build-time dependencies to the environment
67128
packages =
68129
cranePackage.buildInputs
69130
++ cranePackage.nativeBuildInputs
70131
++ (with pkgs; [
71132
cargo-deny
133+
cargo-udeps
72134
evcxr
73135
lldb
74136
self.formatter.${system}

0 commit comments

Comments
 (0)