use rustcSrc

This commit is contained in:
Aaron Janse 2020-10-14 22:54:04 -07:00
parent 015d4e2e98
commit a153be896f
2 changed files with 12 additions and 18 deletions

View file

@ -2,24 +2,18 @@
{ shortTarget, originalCargoToml, target, RUSTFLAGS }:
let rustSrc = stdenv.mkDerivation {
name = "rust-src";
src = rustPlatform.rust.rustc.src;
preferLocalBuild = true;
phases = [ "unpackPhase" "installPhase" ];
installPhase = "cp -r src $out";
};
let
cargoSrc = stdenv.mkDerivation {
name = "cargo-src";
preferLocalBuild = true;
phases = [ "installPhase" ];
installPhase = ''
RUSTC_SRC=${rustSrc} ORIG_CARGO=${originalCargoToml} \
${buildPackages.python3.withPackages (ps: with ps; [ toml ])}/bin/python3 ${./cargo.py}
mkdir -p $out
cp Cargo.toml $out/Cargo.toml
cp ${./Cargo.lock} $out/Cargo.lock
'';
name = "cargo-src";
preferLocalBuild = true;
phases = [ "installPhase" ];
installPhase = ''
RUSTC_SRC=${rustPlatform.rustcSrc} ORIG_CARGO=${originalCargoToml} \
${buildPackages.python3.withPackages (ps: with ps; [ toml ])}/bin/python3 ${./cargo.py}
mkdir -p $out
cp Cargo.toml $out/Cargo.toml
cp ${./Cargo.lock} $out/Cargo.lock
'';
};
in rustPlatform.buildRustPackage {
inherit target RUSTFLAGS;

View file

@ -6,6 +6,6 @@ stdenv.mkDerivation {
phases = [ "unpackPhase" "installPhase" ];
installPhase = ''
mv src $out
rm -rf $out/{ci,doc,etc,grammar,llvm-project,llvm-emscripten,rtstartup,rustllvm,test,tools,vendor,stdarch}
rm -rf $out/{ci,doc,etc,grammar,llvm-project,llvm-emscripten,rtstartup,rustllvm,test,vendor}
'';
}