core/pkgs/build-support/rust/sysroot/src.nix

25 lines
652 B
Nix
Raw Normal View History

2024-05-13 21:24:10 +00:00
{ lib, stdenv, rustPlatform, buildPackages, originalCargoToml ? null }:
2024-05-02 00:46:19 +00:00
stdenv.mkDerivation {
name = "cargo-src";
preferLocalBuild = true;
unpackPhase = "true";
dontConfigure = true;
dontBuild = true;
installPhase = ''
export RUSTC_SRC=${rustPlatform.rustLibSrc.override { }}
2024-05-13 21:24:10 +00:00
'' + lib.optionalString (originalCargoToml != null) ''
2024-05-02 00:46:19 +00:00
export ORIG_CARGO=${originalCargoToml}
2024-05-13 21:24:10 +00:00
'' + ''
${buildPackages.python3.withPackages (ps: with ps; [ toml ])}/bin/python3 ${
./cargo.py
}
2024-05-02 00:46:19 +00:00
mkdir -p $out/src
echo '#![no_std]' > $out/src/lib.rs
cp Cargo.toml $out/Cargo.toml
cp ${./Cargo.lock} $out/Cargo.lock
'';
}