-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attempt make reference happ deps reproducible
- Loading branch information
1 parent
8c3938d
commit 050e514
Showing
10 changed files
with
8,569 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ crateNameFromCargoToml, lib, mkCargoDerivation, mkDummySrc, vendorCargoDeps }: | ||
|
||
{ cargoBuildCommand ? "cargoWithProfile build" | ||
, cargoCheckCommand ? "cargoWithProfile check", cargoExtraArgs ? "--locked" | ||
, cargoTestCommand ? "cargoWithProfile test", cargoTestExtraArgs ? "--no-run" | ||
, ... }@args: | ||
let | ||
crateName = crateNameFromCargoToml args; | ||
cleanedArgs = builtins.removeAttrs args [ | ||
"cargoBuildCommand" | ||
"cargoCheckCommand" | ||
"cargoCheckExtraArgs" | ||
"cargoExtraArgs" | ||
"cargoTestCommand" | ||
"cargoTestExtraArgs" | ||
"outputHashes" | ||
"dummySrc" | ||
"outputs" | ||
]; | ||
|
||
# Run tests by default to ensure we cache any dev-dependencies | ||
doCheck = args.doCheck or true; | ||
|
||
cargoCheckExtraArgs = | ||
args.cargoCheckExtraArgs or (if doCheck then "--all-targets" else ""); | ||
|
||
dummySrc = if args ? dummySrc then | ||
lib.warnIf (args ? src && args.src != null) | ||
"buildDepsOnly will ignore `src` when `dummySrc` is specified" args.dummySrc | ||
else | ||
mkDummySrc args; | ||
in mkCargoDerivation (cleanedArgs // { | ||
inherit doCheck; | ||
|
||
src = dummySrc; | ||
pnameSuffix = "-deps"; | ||
pname = args.pname or crateName.pname; | ||
version = args.version or crateName.version; | ||
|
||
cargoVendorDir = args.cargoVendorDir or (vendorCargoDeps 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} ${cargoCheckExtraArgs} | ||
${cargoBuildCommand} ${cargoExtraArgs} | ||
''; | ||
|
||
checkPhaseCargoCommand = args.checkPhaseCargoCommand or '' | ||
${cargoTestCommand} ${cargoExtraArgs} ${cargoTestExtraArgs} | ||
''; | ||
|
||
# No point in building this if not for the cargo artifacts | ||
doInstallCargoArtifacts = true; | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.