diff options
author | Benjamin Hipple <bhipple@protonmail.com> | 2020-05-06 21:03:41 -0400 |
---|---|---|
committer | Benjamin Hipple <bhipple@protonmail.com> | 2020-05-06 21:03:41 -0400 |
commit | 7f845578afda02eea00f75ffd10bd00fe78b9fa3 (patch) | |
tree | 6a22e9f826ddedee27121fb3d0a447ee14817968 /pkgs/build-support/rust | |
parent | a0c2484d0e650fc8597f3ca7be4bc49192426b3a (diff) | |
download | nixlib-7f845578afda02eea00f75ffd10bd00fe78b9fa3.tar nixlib-7f845578afda02eea00f75ffd10bd00fe78b9fa3.tar.gz nixlib-7f845578afda02eea00f75ffd10bd00fe78b9fa3.tar.bz2 nixlib-7f845578afda02eea00f75ffd10bd00fe78b9fa3.tar.lz nixlib-7f845578afda02eea00f75ffd10bd00fe78b9fa3.tar.xz nixlib-7f845578afda02eea00f75ffd10bd00fe78b9fa3.tar.zst nixlib-7f845578afda02eea00f75ffd10bd00fe78b9fa3.zip |
rustPlatform: fix bug with ambiguous diff tool
If a user provides `nativeBuildInputs = [ llvmPackages.bintools ]` or any other package containing a `${prefix}/bin/diff`, the builder could use it instead of the standard unix `diff`, causing a build failure. This updates the call to specify an abspath to `diff` and avoid reliance on `PATH`. Resolves #87081
Diffstat (limited to 'pkgs/build-support/rust')
-rw-r--r-- | pkgs/build-support/rust/default.nix | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix index 93770d71a10d..a6b47930c274 100644 --- a/pkgs/build-support/rust/default.nix +++ b/pkgs/build-support/rust/default.nix @@ -1,4 +1,14 @@ -{ stdenv, cacert, git, rust, cargo, rustc, fetchCargoTarball, buildPackages, windows }: +{ stdenv +, buildPackages +, cacert +, cargo +, diffutils +, fetchCargoTarball +, git +, rust +, rustc +, windows +}: { name ? "${args.pname}-${args.version}" , cargoSha256 ? "unset" @@ -58,6 +68,10 @@ let cxxForHost="${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++"; releaseDir = "target/${rustTarget}/${buildType}"; + # Specify the stdenv's `diff` by abspath to ensure that the user's build + # inputs do not cause us to find the wrong `diff`. + diff = "${diffutils}/bin/diff"; + in stdenv.mkDerivation (args // { @@ -110,7 +124,7 @@ stdenv.mkDerivation (args // { srcLockfile=$NIX_BUILD_TOP/$sourceRoot/Cargo.lock echo "Validating consistency between $srcLockfile and $cargoDepsLockfile" - if ! diff $srcLockfile $cargoDepsLockfile; then + if ! ${diff} $srcLockfile $cargoDepsLockfile; then # If the diff failed, first double-check that the file exists, so we can # give a friendlier error msg. |