crane/lib/cargoClippy.nix
2022-01-08 17:24:57 -08:00

29 lines
841 B
Nix

{ cargoBuild
, clippy
}:
{ cargoArtifacts
, cargoClippyExtraArgs ? ""
, cargoExtraArgs ? ""
, ...
}@origArgs:
let
args = builtins.removeAttrs origArgs [ "cargoClippyExtraArgs" ];
in
cargoBuild (args // {
inherit cargoArtifacts;
pnameSuffix = "-clippy";
cargoBuildCommand = "cargo clippy --workspace --release --all-targets";
cargoExtraArgs = "${cargoExtraArgs} ${cargoClippyExtraArgs}";
nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [ clippy ];
doCheck = false; # We don't need to run tests to benefit from `cargo check`
# The existence of the build completing without error is enough to ensure
# the checks have passed, so we do not strictly need to install the cargo artifacts.
# However, we allow the caller to retain them if needed.
doInstallCargoArtifacts = args.doInstallCargoArtifacts or false;
})