summary refs log tree commit diff
path: root/pkgs/build-support/rust/default.nix
diff options
context:
space:
mode:
authorzowoq <59103226+zowoq@users.noreply.github.com>2020-09-09 21:39:23 +1000
committerzowoq <59103226+zowoq@users.noreply.github.com>2020-09-24 07:19:58 +1000
commite4c71e6c6c7612f8e0d40ba5b79322f0883fa500 (patch)
treefcd0c2698c73b63ee54b15d8d561673d984d98e5 /pkgs/build-support/rust/default.nix
parenta4d05ec30c6636f8f1268efb8ddf6f9f8b7ca507 (diff)
downloadnixpkgs-e4c71e6c6c7612f8e0d40ba5b79322f0883fa500.tar
nixpkgs-e4c71e6c6c7612f8e0d40ba5b79322f0883fa500.tar.gz
nixpkgs-e4c71e6c6c7612f8e0d40ba5b79322f0883fa500.tar.bz2
nixpkgs-e4c71e6c6c7612f8e0d40ba5b79322f0883fa500.tar.lz
nixpkgs-e4c71e6c6c7612f8e0d40ba5b79322f0883fa500.tar.xz
nixpkgs-e4c71e6c6c7612f8e0d40ba5b79322f0883fa500.tar.zst
nixpkgs-e4c71e6c6c7612f8e0d40ba5b79322f0883fa500.zip
buildRustPackage: support setting test-threads
Diffstat (limited to 'pkgs/build-support/rust/default.nix')
-rw-r--r--pkgs/build-support/rust/default.nix5
1 files changed, 4 insertions, 1 deletions
diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix
index 0103e064828..f6177ce198d 100644
--- a/pkgs/build-support/rust/default.nix
+++ b/pkgs/build-support/rust/default.nix
@@ -30,6 +30,8 @@
 , cargoVendorDir ? null
 , checkType ? buildType
 , depsExtraArgs ? {}
+, cargoParallelTestThreads ? true
+
 # Needed to `pushd`/`popd` into a subdir of a tarball if this subdir
 # contains a Cargo.toml, but isn't part of a workspace (which is e.g. the
 # case for `rustfmt`/etc from the `rust-sources).
@@ -204,11 +206,12 @@ stdenv.mkDerivation ((removeAttrs args ["depsExtraArgs"]) // {
 
   checkPhase = args.checkPhase or (let
     argstr = "${stdenv.lib.optionalString (checkType == "release") "--release"} --target ${rustTarget} --frozen";
+    threads = if cargoParallelTestThreads then "$NIX_BUILD_CORES" else "1";
   in ''
     ${stdenv.lib.optionalString (buildAndTestSubdir != null) "pushd ${buildAndTestSubdir}"}
     runHook preCheck
     echo "Running cargo test ${argstr} -- ''${checkFlags} ''${checkFlagsArray+''${checkFlagsArray[@]}}"
-    cargo test -j $NIX_BUILD_CORES ${argstr} -- --test-threads=$NIX_BUILD_CORES ''${checkFlags} ''${checkFlagsArray+"''${checkFlagsArray[@]}"}
+    cargo test -j $NIX_BUILD_CORES ${argstr} -- --test-threads=${threads} ''${checkFlags} ''${checkFlagsArray+"''${checkFlagsArray[@]}"}
     runHook postCheck
     ${stdenv.lib.optionalString (buildAndTestSubdir != null) "popd"}
   '');