depot/third_party/nixpkgs/pkgs/build-support/rust/rustc-wrapper/default.nix
Default email 504525a148 Project import generated by Copybara.
GitOrigin-RevId: bd645e8668ec6612439a9ee7e71f7eac4099d4f6
2024-01-02 12:29:13 +01: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)}
''