From e32c005772c9f820780453628eb9b7cd9a51223e Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Tue, 24 Mar 2020 18:32:59 +0100 Subject: [PATCH] rustPlatform: don't install test executables This is done by gathering all binaries to install before running the checkPhase. --- pkgs/build-support/rust/default.nix | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix index 6cece004833..9f11919974a 100644 --- a/pkgs/build-support/rust/default.nix +++ b/pkgs/build-support/rust/default.nix @@ -165,6 +165,17 @@ stdenv.mkDerivation (args // { runHook postBuild ''; + postBuild = args.postBuild or "" + '' + + # This needs to be done after postBuild: packages like `cargo` do a pushd/popd in + # the pre/postBuild-hooks that need to be taken into account before gathering + # all binaries to install. + bins=$(find $releaseDir \ + -maxdepth 1 \ + -type f \ + -executable ! \( -regex ".*\.\(so.[0-9.]+\|so\|a\|dylib\)" \)) + ''; + checkPhase = args.checkPhase or (let argstr = "${stdenv.lib.optionalString (buildType == "release") "--release"} --target ${rustTarget} --frozen"; in '' @@ -191,11 +202,7 @@ stdenv.mkDerivation (args // { done mkdir -p $out/bin $out/lib - find $releaseDir \ - -maxdepth 1 \ - -type f \ - -executable ! \( -regex ".*\.\(so.[0-9.]+\|so\|a\|dylib\)" \) \ - -print0 | xargs -r -0 cp -t $out/bin + xargs -r cp -t $out/bin <<< $bins find $releaseDir \ -maxdepth 1 \ -regex ".*\.\(so.[0-9.]+\|so\|a\|dylib\)" \