flake clippy: override build phase to bypass naersk mode

This commit is contained in:
müde 2026-05-14 23:01:13 +02:00
parent ad9e60dad3
commit cf4c84d7c9

View file

@ -126,24 +126,38 @@
checks = forAllSystems ( checks = forAllSystems (
{ {
treefmt-eval, treefmt-eval,
pkgs,
naersk-lib, naersk-lib,
... ...
}: }:
{ {
formatting = treefmt-eval.config.build.check self; formatting = treefmt-eval.config.build.check self;
clippy = naersk-lib.buildPackage { # Clippy as a check: reuse naersk's vendored-deps environment but
# replace the build phase with `cargo clippy --workspace --all-targets
# -- -D warnings`. Naersk's own `mode = "clippy"` mangles the `--`
# separator, so we go through overrideAttrs instead.
clippy =
(naersk-lib.buildPackage {
src = ./.; src = ./.;
mode = "clippy"; # Skip the actual build; we only care about the clippy lint.
cargoBuildOptions = doCheck = false;
orig: copyTarget = false;
orig }).overrideAttrs
++ [ (old: {
"--workspace" pname = "${old.pname}-clippy";
"--" nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.clippy ];
"-D" buildPhase = ''
"warnings" runHook preBuild
]; cargo clippy --workspace --all-targets -- -D warnings
}; runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out
touch $out/.clippy-passed
runHook postInstall
'';
});
} }
); );
}; };