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