nixpkgs/pkgs/build-support/rust/build-rust-package/sysroot/default.nix
John Ericson cbd00bab80 build-support/rust: Split out sysroot src derivation
Hoping to make it usable for `buildRustCrate` too.
2021-11-08 20:38:59 +00:00

32 lines
838 B
Nix

{ stdenv, rust, rustPlatform, buildPackages }:
{ shortTarget, originalCargoToml, target, RUSTFLAGS }:
let
cargoSrc = import ../../sysroot/src.nix {
inherit stdenv rustPlatform buildPackages originalCargoToml;
};
in rustPlatform.buildRustPackage {
inherit target RUSTFLAGS;
name = "custom-sysroot";
src = cargoSrc;
RUSTC_BOOTSTRAP = 1;
__internal_dontAddSysroot = true;
cargoSha256 = "0y6dqfhsgk00y3fv5bnjzk0s7i30nwqc1rp0xlrk83hkh80x81mw";
doCheck = false;
installPhase = ''
export LIBS_DIR=$out/lib/rustlib/${shortTarget}/lib
mkdir -p $LIBS_DIR
for f in target/${shortTarget}/release/deps/*.{rlib,rmeta}; do
cp $f $LIBS_DIR
done
export RUST_SYSROOT=$(rustc --print=sysroot)
host=${rust.toRustTarget stdenv.buildPlatform}
cp -r $RUST_SYSROOT/lib/rustlib/$host $out
'';
}