crane/lib/buildWithCargo.nix
2021-12-26 18:06:19 -08:00

39 lines
744 B
Nix

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