mirror of
https://github.com/ipetkov/crane.git
synced 2024-11-29 21:42:23 +03:00
Add copyCargoTargetToOutputHook
This commit is contained in:
parent
c2d7d083d5
commit
2d9788eb8b
@ -1,23 +1,38 @@
|
|||||||
{ cargo
|
{ cargo
|
||||||
, configureCargoCommonVarsHook
|
, configureCargoCommonVarsHook
|
||||||
, configureCargoVendoredDepsHook
|
, configureCargoVendoredDepsHook
|
||||||
|
, copyCargoTargetToOutputHook
|
||||||
, lib
|
, lib
|
||||||
, stdenv
|
, stdenv
|
||||||
}:
|
}:
|
||||||
|
|
||||||
args@{ nativeBuildInputs ? [ ], ... }:
|
{ doCopyTarget ? true
|
||||||
|
, doCopyTargetToSeparateOutput ? doCopyTarget
|
||||||
|
, nativeBuildInputs ? [ ]
|
||||||
|
, outputs ? [ "out" ]
|
||||||
|
, ...
|
||||||
|
}@args:
|
||||||
stdenv.mkDerivation (args // {
|
stdenv.mkDerivation (args // {
|
||||||
|
inherit
|
||||||
|
doCopyTarget
|
||||||
|
doCopyTargetToSeparateOutput;
|
||||||
|
|
||||||
nativeBuildInputs = nativeBuildInputs ++ [
|
nativeBuildInputs = nativeBuildInputs ++ [
|
||||||
cargo
|
cargo
|
||||||
configureCargoCommonVarsHook
|
configureCargoCommonVarsHook
|
||||||
configureCargoVendoredDepsHook
|
configureCargoVendoredDepsHook
|
||||||
|
copyCargoTargetToOutputHook
|
||||||
];
|
];
|
||||||
|
|
||||||
|
outputs = outputs ++ lib.optional (doCopyTarget && doCopyTargetToSeparateOutput) "target";
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
cargo check --release
|
cargo check --release
|
||||||
'';
|
'';
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
touch $out
|
runHook preInstall
|
||||||
|
mkdir -p $out
|
||||||
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
21
pkgs/copyCargoTargetToOutputHook.sh
Normal file
21
pkgs/copyCargoTargetToOutputHook.sh
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
copyCargoTargetToOutput() {
|
||||||
|
echo "Executing copyCargoTargetToOutput"
|
||||||
|
trap "echo Finished copyCargoTargetToOutput" RETURN
|
||||||
|
|
||||||
|
local target_dir=${CARGO_TARGET_DIR:-target}
|
||||||
|
|
||||||
|
if [ "1" != "${doCopyTarget}" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "1" = "${doCopyTargetToSeparateOutput}" ]; then
|
||||||
|
local dest="${target}"
|
||||||
|
else
|
||||||
|
mkdir -p "${out}"
|
||||||
|
local dest="${out}/target"
|
||||||
|
fi
|
||||||
|
|
||||||
|
mv "${target_dir}" "${dest}"
|
||||||
|
}
|
||||||
|
|
||||||
|
postInstallHooks+=(copyCargoTargetToOutput)
|
@ -10,4 +10,9 @@
|
|||||||
{
|
{
|
||||||
name = "configureCargoVendoredDepsHook";
|
name = "configureCargoVendoredDepsHook";
|
||||||
} ./configureCargoVendoredDepsHook.sh;
|
} ./configureCargoVendoredDepsHook.sh;
|
||||||
|
|
||||||
|
copyCargoTargetToOutputHook = makeSetupHook
|
||||||
|
{
|
||||||
|
name = "copyCargoTargetToOutputHook";
|
||||||
|
} ./copyCargoTargetToOutputHook.sh;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user