mirror of
https://github.com/ipetkov/crane.git
synced 2024-11-27 02:52:02 +03:00
dc553e3853
* This hook was never a great implementation to begin with since it would simply search the cargo artifacts directory for binaries and libraries to install * This isn't really great since if we have multiple builds (say one with debug artifacts, one with release artifacts) it isn't exactly clear which artifacts would get installed (or which will get clobbered). * Now that we have installFromCargoBuildLogHook we can simplify the options a bit and only have one main installation method. The caller can always provide their own if they wish
38 lines
1.1 KiB
Nix
38 lines
1.1 KiB
Nix
{ crateNameFromCargoToml
|
|
, mkCargoDerivation
|
|
, mkDummySrc
|
|
, vendorCargoDepsFromArgs
|
|
}:
|
|
|
|
{ cargoExtraArgs ? ""
|
|
, cargoCheckCommand ? "cargo check --workspace --release"
|
|
, cargoBuildCommand ? "cargo build --workspace --release"
|
|
, cargoTestCommand ? "cargo test --workspace --release"
|
|
, ...
|
|
}@args:
|
|
let
|
|
crateName = crateNameFromCargoToml args;
|
|
in
|
|
mkCargoDerivation (args // {
|
|
src = mkDummySrc args;
|
|
pname = args.pname or "${crateName.pname}-deps";
|
|
version = args.version or crateName.version;
|
|
|
|
cargoArtifacts = null;
|
|
cargoVendorDir = args.cargoVendorDir or vendorCargoDepsFromArgs args;
|
|
|
|
# First we run `cargo check` to cache cargo's internal artifacts, fingerprints, etc. for all deps.
|
|
# Then we run `cargo build` to actually compile the deps and cache the results
|
|
buildPhaseCargoCommand = args.buildPhaseCargoCommand or ''
|
|
${cargoCheckCommand} ${cargoExtraArgs}
|
|
${cargoBuildCommand} ${cargoExtraArgs}
|
|
'';
|
|
|
|
checkPhaseCargoCommand = args.checkPhaseCargoCommand or ''
|
|
${cargoTestCommand} ${cargoExtraArgs}
|
|
'';
|
|
|
|
# No point in building this if not for the cargo artifacts
|
|
doCopyTargetToOutput = true;
|
|
})
|