cargoClippy: use mkCargoDerivation instead of cargoBuild

This commit is contained in:
Ivan Petkov 2022-10-09 12:02:17 -07:00
parent 0ad37656bc
commit 2b70a82caf
3 changed files with 12 additions and 13 deletions

View File

@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* `mkCargoDerivation` now defaults to an empty `checkPhaseCargoCommand` if not
specified
* `cargoAudit` now delegates to `mkCargoDerivation` instead of `cargoBuild`
* `cargoClippy` now delegates to `mkCargoDerivation` instead of `cargoBuild`
* `cargoDoc` now delegates to `mkCargoDerivation` instead of `cargoBuild`
* `cargoFmt` now delegates to `mkCargoDerivation` instead of `cargoBuild`
* `cargoTarpaulin` now delegates to `mkCargoDerivation` instead of `cargoBuild`

View File

@ -312,15 +312,12 @@ Create a derivation which will run a `cargo clippy` invocation in a cargo
workspace.
Except where noted below, all derivation attributes are delegated to
`cargoBuild`, and can be used to influence its behavior.
* `cargoBuildCommand` will be set to run `cargo clippy --profile release` for
`mkCargoDerivation`, and can be used to influence its behavior.
* `buildPhaseCargoCommand` will be set to run `cargo clippy --profile release` for
the workspace.
- `CARGO_PROFILE` can be set on the derivation to alter which cargo profile
is selected; setting it to `""` will omit specifying a profile
altogether.
* `cargoExtraArgs` will have `cargoClippyExtraArgs` appended to it
- Default value: `"--all-targets"`
* `doCheck` is disabled
* `pnameSuffix` will be set to `"-clippy"`
#### Required attributes
@ -349,6 +346,7 @@ The following attributes will be removed before being lowered to
environment variables during the build, you can bring them back via
`.overrideAttrs`.
* `cargoClippyExtraArgs`
* `cargoExtraArgs`
### `lib.cargoDoc`

View File

@ -1,5 +1,5 @@
{ cargoBuild
, clippy
{ clippy
, mkCargoDerivation
}:
{ cargoArtifacts
@ -8,16 +8,16 @@
, ...
}@origArgs:
let
args = builtins.removeAttrs origArgs [ "cargoClippyExtraArgs" ];
args = builtins.removeAttrs origArgs [
"cargoClippyExtraArgs"
"cargoExtraArgs"
];
in
cargoBuild (args // {
mkCargoDerivation (args // {
inherit cargoArtifacts;
pnameSuffix = "-clippy";
cargoBuildCommand = "cargoWithProfile clippy";
cargoExtraArgs = "${cargoExtraArgs} ${cargoClippyExtraArgs}";
buildPhaseCargoCommand = "cargoWithProfile clippy ${cargoExtraArgs} ${cargoClippyExtraArgs}";
nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [ clippy ];
doCheck = false; # We don't need to run tests to benefit from `cargo clippy`
})