2022-01-03 01:48:32 +03:00
|
|
|
{ cargo
|
2022-07-23 20:04:55 +03:00
|
|
|
, cargoHelperFunctionsHook
|
2022-01-03 01:48:32 +03:00
|
|
|
, configureCargoCommonVarsHook
|
|
|
|
, configureCargoVendoredDepsHook
|
|
|
|
, inheritCargoArtifactsHook
|
2022-01-09 04:14:05 +03:00
|
|
|
, installCargoArtifactsHook
|
2022-01-04 20:48:22 +03:00
|
|
|
, lib
|
2022-01-03 01:48:32 +03:00
|
|
|
, stdenv
|
|
|
|
}:
|
|
|
|
|
|
|
|
args@{
|
|
|
|
# A directory to an existing cargo `target` directory, which will be reused
|
|
|
|
# at the start of the derivation. Useful for caching incremental cargo builds.
|
|
|
|
cargoArtifacts
|
|
|
|
# A directory of vendored cargo sources which can be consumed without network
|
|
|
|
# access. Directory structure should basically follow the output of `cargo vendor`.
|
|
|
|
, cargoVendorDir
|
|
|
|
# A command (likely a cargo invocation) to run during the derivation's build
|
|
|
|
# phase. Pre and post build hooks will automatically be run.
|
|
|
|
, buildPhaseCargoCommand
|
|
|
|
# A command (likely a cargo invocation) to run during the derivation's check
|
|
|
|
# phase. Pre and post check hooks will automatically be run.
|
|
|
|
, checkPhaseCargoCommand
|
2022-01-04 01:39:57 +03:00
|
|
|
# A command to run during the derivation's install
|
2022-01-03 01:48:32 +03:00
|
|
|
# phase. Pre and post install hooks will automatically be run.
|
2022-01-04 01:39:57 +03:00
|
|
|
, installPhaseCommand ? "mkdir -p $out"
|
2022-01-03 01:48:32 +03:00
|
|
|
, ...
|
|
|
|
}:
|
2022-01-05 04:45:31 +03:00
|
|
|
let
|
2022-09-15 20:20:48 +03:00
|
|
|
chosenStdenv = args.stdenv or stdenv;
|
2022-01-05 04:45:31 +03:00
|
|
|
cleanedArgs = builtins.removeAttrs args [
|
|
|
|
"buildPhaseCargoCommand"
|
|
|
|
"checkPhaseCargoCommand"
|
|
|
|
"installPhaseCommand"
|
|
|
|
"pnameSuffix"
|
2022-09-15 20:20:48 +03:00
|
|
|
"stdenv"
|
2022-01-05 04:45:31 +03:00
|
|
|
];
|
|
|
|
in
|
2022-09-15 20:20:48 +03:00
|
|
|
chosenStdenv.mkDerivation (cleanedArgs // {
|
2022-01-05 04:45:31 +03:00
|
|
|
pname = "${args.pname}${args.pnameSuffix or ""}";
|
|
|
|
|
2022-01-03 01:48:32 +03:00
|
|
|
# Controls whether cargo's `target` directory should be copied as an output
|
2022-01-09 04:14:05 +03:00
|
|
|
doInstallCargoArtifacts = args.doInstallCargoArtifacts or true;
|
2022-01-03 01:48:32 +03:00
|
|
|
|
|
|
|
nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [
|
|
|
|
cargo
|
2022-07-23 20:04:55 +03:00
|
|
|
cargoHelperFunctionsHook
|
2022-01-03 01:48:32 +03:00
|
|
|
configureCargoCommonVarsHook
|
|
|
|
configureCargoVendoredDepsHook
|
|
|
|
inheritCargoArtifactsHook
|
2022-01-09 04:14:05 +03:00
|
|
|
installCargoArtifactsHook
|
2022-01-03 01:48:32 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
buildPhase = args.buildPhase or ''
|
|
|
|
runHook preBuild
|
2022-01-08 07:48:52 +03:00
|
|
|
cargo --version
|
2022-01-03 01:48:32 +03:00
|
|
|
${buildPhaseCargoCommand}
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
checkPhase = args.checkPhase or ''
|
|
|
|
runHook preCheck
|
|
|
|
${checkPhaseCargoCommand}
|
|
|
|
runHook postCheck
|
|
|
|
'';
|
|
|
|
|
2022-09-18 04:18:03 +03:00
|
|
|
configurePhase = args.configurePhase or ''
|
|
|
|
runHook preConfigure
|
|
|
|
echo default configurePhase, nothing to do
|
|
|
|
runHook postConfigure
|
|
|
|
'';
|
|
|
|
|
2022-01-03 01:48:32 +03:00
|
|
|
installPhase = args.installPhase or ''
|
|
|
|
runHook preInstall
|
2022-01-04 01:39:57 +03:00
|
|
|
${installPhaseCommand}
|
2022-01-03 01:48:32 +03:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
})
|