Skip to content

Commit

Permalink
Attempt make reference happ deps reproducible
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed May 29, 2024
1 parent 8c3938d commit 050e514
Show file tree
Hide file tree
Showing 10 changed files with 8,569 additions and 48 deletions.
56 changes: 56 additions & 0 deletions nix/buildDepsOnlyWithArtifacts.nix
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;
})

2 changes: 1 addition & 1 deletion nix/fixtures/module-repo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ resolver = "2"
hdi = "0.4.1-rc"
hdk = "0.3.1-rc"
holochain = "0.3.1-rc"
serde = "1"
serde = "1.0.197"

[profile.release]
opt-level = "z"
44 changes: 22 additions & 22 deletions nix/fixtures/module-repo/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions nix/fixtures/module-repo/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion nix/fixtures/module-repo/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"start": "node index.js"
},
"dependencies": {
"@holochain-open-dev/profiles": "github:holochain-open-dev/profiles#7dc05a2c5e681fb32d3faef5be297f14cf3d7402&path:ui"
"@holochain-open-dev/profiles": "github:holochain-open-dev/profiles#f95cd9b627a308dcac016b47df960dbb24b741b8&path:ui"
},
"exports": {
".": "./index.js"
Expand Down
Loading

0 comments on commit 050e514

Please sign in to comment.