crane/lib/buildWithCargo.nix

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