diff --git a/pkgs/build-support/rust/rustc-wrapper/default.nix b/pkgs/build-support/rust/rustc-wrapper/default.nix index 2b4a84e72b24..0defa6355029 100644 --- a/pkgs/build-support/rust/rustc-wrapper/default.nix +++ b/pkgs/build-support/rust/rustc-wrapper/default.nix @@ -6,7 +6,6 @@ runCommand "${rustc-unwrapped.pname}-wrapper-${rustc-unwrapped.version}" { inherit (rustc-unwrapped) outputs; env = { - prog = "${rustc-unwrapped}/bin/rustc"; sysroot = lib.optionalString (sysroot != null) "--sysroot ${sysroot}"; # Upstream rustc still assumes that musl = static[1]. The fix for @@ -42,9 +41,12 @@ runCommand "${rustc-unwrapped.pname}-wrapper-${rustc-unwrapped.version}" { } '' mkdir -p $out/bin ln -s ${rustc-unwrapped}/bin/* $out/bin - rm $out/bin/rustc - substituteAll ${./rustc-wrapper.sh} $out/bin/rustc - chmod +x $out/bin/rustc + rm $out/bin/{rustc,rustdoc} + prog=${rustc-unwrapped}/bin/rustc extraFlagsVar=NIX_RUSTFLAGS \ + substituteAll ${./rustc-wrapper.sh} $out/bin/rustc + prog=${rustc-unwrapped}/bin/rustdoc extraFlagsVar=NIX_RUSTDOCFLAGS \ + substituteAll ${./rustc-wrapper.sh} $out/bin/rustdoc + chmod +x $out/bin/{rustc,rustdoc} ${lib.concatMapStrings (output: "ln -s ${rustc-unwrapped.${output}} \$${output}\n") (lib.remove "out" rustc-unwrapped.outputs)} '' diff --git a/pkgs/build-support/rust/rustc-wrapper/rustc-wrapper.sh b/pkgs/build-support/rust/rustc-wrapper/rustc-wrapper.sh index 63e18be2e131..e33cc3e2a025 100644 --- a/pkgs/build-support/rust/rustc-wrapper/rustc-wrapper.sh +++ b/pkgs/build-support/rust/rustc-wrapper/rustc-wrapper.sh @@ -14,7 +14,7 @@ for arg; do done extraBefore=(@defaultArgs@ "${defaultSysroot[@]}") -extraAfter=($NIX_RUSTFLAGS) +extraAfter=($@extraFlagsVar@) # Optionally print debug info. if (( "${NIX_DEBUG:-0}" >= 1 )); then diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix index 9235519eee1f..0a4a351b1cfd 100644 --- a/pkgs/development/compilers/rust/rustc.nix +++ b/pkgs/development/compilers/rust/rustc.nix @@ -175,8 +175,7 @@ in stdenv.mkDerivation (finalAttrs: { python ./x.py --keep-stage=0 --stage=1 install library/std mkdir -v $out/bin $doc $man - ln -s ${rustc.unwrapped}/bin/rustc $out/bin - makeWrapper ${rustc.unwrapped}/bin/rustdoc $out/bin/rustdoc --add-flags "--sysroot $out" + ln -s ${rustc.unwrapped}/bin/{rustc,rustdoc} $out/bin ln -s ${rustc.unwrapped}/lib/rustlib/{manifest-rust-std-,}${stdenv.hostPlatform.rust.rustcTargetSpec} $out/lib/rustlib/ echo rust-std-${stdenv.hostPlatform.rust.rustcTargetSpec} >> $out/lib/rustlib/components lndir ${rustc.doc} $doc