Merge pull request #24926 from Mic92/rust-package
buildRustPackage: cargoBuildFlags + standarized hooks
This commit is contained in:
commit
3fae96f056
@ -7,6 +7,7 @@
|
|||||||
, buildInputs ? []
|
, buildInputs ? []
|
||||||
, cargoUpdateHook ? ""
|
, cargoUpdateHook ? ""
|
||||||
, cargoDepsHook ? ""
|
, cargoDepsHook ? ""
|
||||||
|
, cargoBuildFlags ? []
|
||||||
, ... } @ args:
|
, ... } @ args:
|
||||||
|
|
||||||
let
|
let
|
||||||
@ -26,7 +27,11 @@ in stdenv.mkDerivation (args // {
|
|||||||
|
|
||||||
buildInputs = [ git rust.cargo rust.rustc ] ++ buildInputs;
|
buildInputs = [ git rust.cargo rust.rustc ] ++ buildInputs;
|
||||||
|
|
||||||
configurePhase = args.configurePhase or "true";
|
configurePhase = args.configurePhase or ''
|
||||||
|
runHook preConfigure
|
||||||
|
# noop
|
||||||
|
runHook postConfigure
|
||||||
|
'';
|
||||||
|
|
||||||
postUnpack = ''
|
postUnpack = ''
|
||||||
eval "$cargoDepsHook"
|
eval "$cargoDepsHook"
|
||||||
@ -92,22 +97,26 @@ in stdenv.mkDerivation (args // {
|
|||||||
)
|
)
|
||||||
'' + (args.prePatch or "");
|
'' + (args.prePatch or "");
|
||||||
|
|
||||||
buildPhase = args.buildPhase or ''
|
buildPhase = with builtins; args.buildPhase or ''
|
||||||
echo "Running cargo build --release"
|
runHook preBuild
|
||||||
cargo build --release
|
echo "Running cargo build --release ${concatStringsSep " " cargoBuildFlags}"
|
||||||
|
cargo build --release ${concatStringsSep " " cargoBuildFlags}
|
||||||
|
runHook postBuild
|
||||||
'';
|
'';
|
||||||
|
|
||||||
checkPhase = args.checkPhase or ''
|
checkPhase = args.checkPhase or ''
|
||||||
|
runHook preCheck
|
||||||
echo "Running cargo test"
|
echo "Running cargo test"
|
||||||
cargo test
|
cargo test
|
||||||
|
runHook postCheck
|
||||||
'';
|
'';
|
||||||
|
|
||||||
doCheck = args.doCheck or true;
|
doCheck = args.doCheck or true;
|
||||||
|
|
||||||
installPhase = args.installPhase or ''
|
installPhase = args.installPhase or ''
|
||||||
|
runHook preInstall
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
for f in $(find target/release -maxdepth 1 -type f); do
|
find target/release -maxdepth 1 -executable -exec cp "{}" $out/bin \;
|
||||||
cp $f $out/bin
|
runHook postInstall
|
||||||
done;
|
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user