2023-02-08 23:40:38 +01:00
|
|
|
{ lib, stdenv, rust, rustPlatform, buildPackages }:
|
2020-10-08 14:32:49 -07:00
|
|
|
|
|
|
|
{ shortTarget, originalCargoToml, target, RUSTFLAGS }:
|
|
|
|
|
2020-10-14 22:54:04 -07:00
|
|
|
let
|
2021-10-07 22:20:10 +00:00
|
|
|
cargoSrc = import ../../sysroot/src.nix {
|
2023-02-08 23:40:38 +01:00
|
|
|
inherit lib stdenv rustPlatform buildPackages originalCargoToml;
|
2020-10-08 14:32:49 -07:00
|
|
|
};
|
|
|
|
in rustPlatform.buildRustPackage {
|
|
|
|
inherit target RUSTFLAGS;
|
|
|
|
|
|
|
|
name = "custom-sysroot";
|
|
|
|
src = cargoSrc;
|
|
|
|
|
|
|
|
RUSTC_BOOTSTRAP = 1;
|
|
|
|
__internal_dontAddSysroot = true;
|
2023-02-09 01:13:21 +01:00
|
|
|
cargoSha256 = "sha256-zgkwevitxsu1C4OgGTsqNSc0gDxaNXYK1WPbfER48d0=";
|
2020-10-12 14:48:07 -07:00
|
|
|
|
|
|
|
doCheck = false;
|
2020-10-08 14:32:49 -07:00
|
|
|
|
|
|
|
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)
|
2020-10-14 03:37:29 +00:00
|
|
|
host=${rust.toRustTarget stdenv.buildPlatform}
|
|
|
|
cp -r $RUST_SYSROOT/lib/rustlib/$host $out
|
2020-10-08 14:32:49 -07:00
|
|
|
'';
|
2023-02-24 21:53:45 +01:00
|
|
|
|
|
|
|
# allows support for cross-compilation
|
|
|
|
meta.platforms = lib.platforms.all;
|
2020-10-08 14:32:49 -07:00
|
|
|
}
|