nixpkgs/pkgs/build-support/rust/rustc-wrapper/default.nix
Alyssa Ross 8929ba838f rustc: use the wrapper for fastCross sysroot
This avoids having two layers of wrapper for cross rustc.
2023-11-30 09:23:06 +00:00

30 lines
907 B
Nix

{ lib, runCommand, rustc-unwrapped, sysroot ? null }:
runCommand "${rustc-unwrapped.pname}-wrapper-${rustc-unwrapped.version}" {
preferLocalBuild = true;
strictDeps = true;
inherit (rustc-unwrapped) outputs;
env = {
prog = "${rustc-unwrapped}/bin/rustc";
sysroot = lib.optionalString (sysroot != null) "--sysroot ${sysroot}";
};
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)}
''