summary refs log tree commit diff
path: root/pkgs/build-support/rust/default.nix
diff options
context:
space:
mode:
authorAaron Janse <aaron@ajanse.me>2020-10-17 00:45:27 -0700
committerAaron Janse <aaron@ajanse.me>2020-10-17 00:45:27 -0700
commitdec97eb3e99be60cbf865d079e1d3215578bbf73 (patch)
tree27939091c14f7078a6a61fc3a1afeb2adc7f861a /pkgs/build-support/rust/default.nix
parent116ac11652659c0f896fda4a2477152b92e5326a (diff)
downloadnixpkgs-dec97eb3e99be60cbf865d079e1d3215578bbf73.tar
nixpkgs-dec97eb3e99be60cbf865d079e1d3215578bbf73.tar.gz
nixpkgs-dec97eb3e99be60cbf865d079e1d3215578bbf73.tar.bz2
nixpkgs-dec97eb3e99be60cbf865d079e1d3215578bbf73.tar.lz
nixpkgs-dec97eb3e99be60cbf865d079e1d3215578bbf73.tar.xz
nixpkgs-dec97eb3e99be60cbf865d079e1d3215578bbf73.tar.zst
nixpkgs-dec97eb3e99be60cbf865d079e1d3215578bbf73.zip
minor clean up
Diffstat (limited to 'pkgs/build-support/rust/default.nix')
-rw-r--r--pkgs/build-support/rust/default.nix5
1 files changed, 3 insertions, 2 deletions
diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix
index 2575c7f3107..e027853255c 100644
--- a/pkgs/build-support/rust/default.nix
+++ b/pkgs/build-support/rust/default.nix
@@ -77,6 +77,7 @@ let
     '';
 
   targetIsJSON = stdenv.lib.hasSuffix ".json" target;
+  useSysroot = targetIsJSON && !__internal_dontAddSysroot;
 
   # see https://github.com/rust-lang/cargo/blob/964a16a28e234a3d397b2a7031d4ab4a428b1391/src/cargo/core/compiler/compile_kind.rs#L151-L168
   # the "${}" is needed to transform the path into a /nix/store path before baseNameOf
@@ -202,8 +203,8 @@ stdenv.mkDerivation ((removeAttrs args ["depsExtraArgs"]) // {
       "CXX_${rust.toRustTarget stdenv.buildPlatform}"="${cxxForBuild}" \
       "CC_${rust.toRustTarget stdenv.hostPlatform}"="${ccForHost}" \
       "CXX_${rust.toRustTarget stdenv.hostPlatform}"="${cxxForHost}" \
-      ${stdenv.lib.optionalString
-          (targetIsJSON && !__internal_dontAddSysroot) "RUSTFLAGS=\"--sysroot ${sysroot} $RUSTFLAGS\" "
+      ${stdenv.lib.optionalString useSysroot
+         "RUSTFLAGS=\"--sysroot ${sysroot} $RUSTFLAGS\" "
       }cargo build -j $NIX_BUILD_CORES \
         ${stdenv.lib.optionalString (buildType == "release") "--release"} \
         --target ${target} \