From 8c97f0644890c4e787444a303c11b4347bb860ca Mon Sep 17 00:00:00 2001 From: Ivan Petkov Date: Sun, 9 Oct 2022 11:53:55 -0700 Subject: [PATCH] cargoAudit: use mkCargoDerivation instead of cargoBuild --- CHANGELOG.md | 1 + docs/API.md | 10 ++++------ lib/cargoAudit.nix | 13 +++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e6d0df5..7b0cd783 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. `crateNameFromCargoToml`) if they are not specified * `mkCargoDerivation` now defaults to an empty `checkPhaseCargoCommand` if not specified +* `cargoAudit` now delegates to `mkCargoDerivation` instead of `cargoBuild` * `cargoDoc` now delegates to `mkCargoDerivation` instead of `cargoBuild` * `cargoFmt` now delegates to `mkCargoDerivation` instead of `cargoBuild` diff --git a/docs/API.md b/docs/API.md index 442826ec..21ad694d 100644 --- a/docs/API.md +++ b/docs/API.md @@ -190,14 +190,11 @@ Create a derivation which will run a `cargo audit` invocation in a cargo workspace. Except where noted below, all derivation attributes are delegated to -`cargoBuild`, and can be used to influence its behavior. -* `cargoArtifacts` will be set to `null` as they are not needed -* `cargoBuildCommand` will be set to run `cargo audit -n -d ${advisory-db}` in +`mkCargoDerivation`, and can be used to influence its behavior. +* `buildPhaseCargoCommand` will be set to run `cargo audit -n -d ${advisory-db}` in the workspace. -* `cargoExtraArgs` will have `cargoAuditExtraArgs` appended to it - - Default value: `""` +* `cargoArtifacts` will be set to `null` as they are not needed * `cargoVendorDir` will be set to `null` as it is not needed -* `doCheck` is disabled * `doInstallCargoArtifacts` is disabled * `pnameSuffix` will be set to `"-audit"` * `src` will be filtered to only keep `Cargo.lock` files @@ -233,6 +230,7 @@ The following attributes will be removed before being lowered to environment variables during the build, you can bring them back via `.overrideAttrs`. * `cargoAuditExtraArgs` +* `cargoExtraArgs` ### `lib.cargoBuild` diff --git a/lib/cargoAudit.nix b/lib/cargoAudit.nix index b1decb6e..5c785428 100644 --- a/lib/cargoAudit.nix +++ b/lib/cargoAudit.nix @@ -1,6 +1,6 @@ { cargo-audit -, cargoBuild , lib +, mkCargoDerivation }: { advisory-db @@ -10,11 +10,13 @@ , ... }@origArgs: let - args = builtins.removeAttrs origArgs [ "cargoAuditExtraArgs" ]; + args = builtins.removeAttrs origArgs [ + "cargoAuditExtraArgs" + "cargoExtraArgs" + ]; in -cargoBuild (args // { - cargoBuildCommand = "cargo audit -n -d ${advisory-db}"; - cargoExtraArgs = "${cargoExtraArgs} ${cargoAuditExtraArgs}"; +mkCargoDerivation (args // { + buildPhaseCargoCommand = "cargo audit ${cargoExtraArgs} -n -d ${advisory-db} ${cargoAuditExtraArgs}"; src = lib.cleanSourceWith { inherit src; @@ -27,7 +29,6 @@ cargoBuild (args // { cargoArtifacts = null; # Don't need artifacts, just Cargo.lock cargoVendorDir = null; # Don't need dependencies either - doCheck = false; # We don't need to run tests to benefit from `cargo audit` doInstallCargoArtifacts = false; # We don't expect to/need to install artifacts pnameSuffix = "-audit";