2021-10-07 23:20:10 +01:00
|
|
|
{ lib, stdenv, rustPlatform, buildPackages
|
|
|
|
, originalCargoToml ? null
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "cargo-src";
|
|
|
|
preferLocalBuild = true;
|
2021-11-08 21:38:58 +00:00
|
|
|
|
|
|
|
unpackPhase = "true";
|
|
|
|
dontConfigure = true;
|
|
|
|
dontBuild = true;
|
|
|
|
|
2021-10-07 23:20:10 +01:00
|
|
|
installPhase = ''
|
2021-11-08 02:05:25 +00:00
|
|
|
export RUSTC_SRC=${rustPlatform.rustLibSrc.override { }}
|
2021-10-07 23:20:10 +01:00
|
|
|
''
|
|
|
|
+ lib.optionalString (originalCargoToml != null) ''
|
|
|
|
export ORIG_CARGO=${originalCargoToml}
|
|
|
|
''
|
|
|
|
+ ''
|
|
|
|
${buildPackages.python3.withPackages (ps: with ps; [ toml ])}/bin/python3 ${./cargo.py}
|
2021-11-08 02:05:25 +00:00
|
|
|
mkdir -p $out/src
|
|
|
|
touch $out/src/lib.rs
|
2021-10-07 23:20:10 +01:00
|
|
|
cp Cargo.toml $out/Cargo.toml
|
|
|
|
cp ${./Cargo.lock} $out/Cargo.lock
|
|
|
|
'';
|
|
|
|
}
|