diff options
Diffstat (limited to 'pkgs/build-support/rust')
-rw-r--r-- | pkgs/build-support/rust/rustc-wrapper/default.nix | 29 | ||||
-rw-r--r-- | pkgs/build-support/rust/rustc-wrapper/rustc-wrapper.sh | 11 |
2 files changed, 40 insertions, 0 deletions
diff --git a/pkgs/build-support/rust/rustc-wrapper/default.nix b/pkgs/build-support/rust/rustc-wrapper/default.nix new file mode 100644 index 000000000000..06cfcbb5457f --- /dev/null +++ b/pkgs/build-support/rust/rustc-wrapper/default.nix @@ -0,0 +1,29 @@ +{ lib, runCommand, rustc-unwrapped }: + +runCommand "${rustc-unwrapped.pname}-wrapper-${rustc-unwrapped.version}" { + preferLocalBuild = true; + strictDeps = true; + inherit (rustc-unwrapped) outputs; + + env = { + prog = "${rustc-unwrapped}/bin/rustc"; + }; + + passthru = { + inherit (rustc-unwrapped) pname version src llvm llvmPackages; + unwrapped = rustc-unwrapped; + }; + + meta = rustc-unwrapped.meta // { + description = "${rustc-unwrapped.meta.description} (wrapper script)"; + priority = 10; + }; +} '' + 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 + ${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 new file mode 100644 index 000000000000..866a6912e090 --- /dev/null +++ b/pkgs/build-support/rust/rustc-wrapper/rustc-wrapper.sh @@ -0,0 +1,11 @@ +#!@shell@ + +# Optionally print debug info. +if (( "${NIX_DEBUG:-0}" >= 1 )); then + echo "original flags to @prog@:" >&2 + printf " %q\n" "$@" >&2 + echo "extra flags after to @prog@:" >&2 + printf " %q\n" $NIX_RUSTFLAGS >&2 +fi + +exec @prog@ "$@" $NIX_RUSTFLAGS |