crane/lib/buildWithCargo.nix

39 lines
744 B
Nix
Raw Normal View History

{ cargo
2021-12-27 04:10:04 +03:00
, configureCargoCommonVarsHook
, configureCargoVendoredDepsHook
2021-12-27 05:06:19 +03:00
, copyCargoTargetToOutputHook
, lib
, stdenv
}:
2021-12-27 05:06:19 +03:00
{ doCopyTarget ? true
, doCopyTargetToSeparateOutput ? doCopyTarget
, nativeBuildInputs ? [ ]
, outputs ? [ "out" ]
, ...
}@args:
stdenv.mkDerivation (args // {
2021-12-27 05:06:19 +03:00
inherit
doCopyTarget
doCopyTargetToSeparateOutput;
nativeBuildInputs = nativeBuildInputs ++ [
cargo
2021-12-27 04:10:04 +03:00
configureCargoCommonVarsHook
configureCargoVendoredDepsHook
2021-12-27 05:06:19 +03:00
copyCargoTargetToOutputHook
];
2021-12-27 05:06:19 +03:00
outputs = outputs ++ lib.optional (doCopyTarget && doCopyTargetToSeparateOutput) "target";
buildPhase = ''
cargo check --release
'';
installPhase = ''
2021-12-27 05:06:19 +03:00
runHook preInstall
mkdir -p $out
runHook postInstall
'';
})