diff --git a/CHANGELOG.md b/CHANGELOG.md index 44270530..5910099e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## Unreleased +### Added +* `cargoBench` can now be used to run cargo benchmarks + ### Changed * A warning will now be emitted if a derivation's `pname` or `version` attributes are not set and the value cannot be loaded from the derivation's diff --git a/lib/cargoBench.nix b/lib/cargoBench.nix new file mode 100644 index 00000000..1954bf9d --- /dev/null +++ b/lib/cargoBench.nix @@ -0,0 +1,18 @@ +{ mkCargoDerivation +}: + +{ cargoExtraArgs ? "" +, cargoBenchExtraArgs ? "" +, ... +}@origArgs: +let + args = builtins.removeAttrs origArgs [ + "cargoExtraArgs" + "cargoBenchExtraArgs" + ]; +in +mkCargoDerivation (args // { + pnameSuffix = "-bench"; + + buildPhaseCargoCommand = "cargoWithProfile bench ${cargoExtraArgs} ${cargoBenchExtraArgs}"; +}) diff --git a/lib/default.nix b/lib/default.nix index 35a4fd84..839342fe 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -14,6 +14,7 @@ in buildDepsOnly = callPackage ./buildDepsOnly.nix { }; buildPackage = callPackage ./buildPackage.nix { }; cargoAudit = callPackage ./cargoAudit.nix { }; + cargoBench = callPackage ./cargoBench.nix { }; cargoBuild = callPackage ./cargoBuild.nix { }; cargoClippy = callPackage ./cargoClippy.nix { }; cargoDoc = callPackage ./cargoDoc.nix { };