build-support/rust: Split out sysroot src derivation
Hoping to make it usable for `buildRustCrate` too.
This commit is contained in:
parent
2c7f62379f
commit
cbd00bab80
|
@ -3,17 +3,8 @@
|
|||
{ shortTarget, originalCargoToml, target, RUSTFLAGS }:
|
||||
|
||||
let
|
||||
cargoSrc = stdenv.mkDerivation {
|
||||
name = "cargo-src";
|
||||
preferLocalBuild = true;
|
||||
phases = [ "installPhase" ];
|
||||
installPhase = ''
|
||||
RUSTC_SRC=${rustPlatform.rustcSrc.override { minimalContent = false; }} 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
|
||||
'';
|
||||
cargoSrc = import ../../sysroot/src.nix {
|
||||
inherit stdenv rustPlatform buildPackages originalCargoToml;
|
||||
};
|
||||
in rustPlatform.buildRustPackage {
|
||||
inherit target RUSTFLAGS;
|
||||
|
|
21
pkgs/build-support/rust/sysroot/src.nix
Normal file
21
pkgs/build-support/rust/sysroot/src.nix
Normal file
|
@ -0,0 +1,21 @@
|
|||
{ lib, stdenv, rustPlatform, buildPackages
|
||||
, originalCargoToml ? null
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "cargo-src";
|
||||
preferLocalBuild = true;
|
||||
phases = [ "installPhase" ];
|
||||
installPhase = ''
|
||||
export RUSTC_SRC=${rustPlatform.rustcSrc.override { minimalContent = false; }}
|
||||
''
|
||||
+ lib.optionalString (originalCargoToml != null) ''
|
||||
export 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
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue