Skip to content

Commit a8264df

Browse files
committed
feat(zkvmLib): Add the ability to override dependencies
Allows you to add `overrideVendorCargoPackage` and `overrideVendorGitCheckout` to args, which allow the overriding of vendored dependencies, as is implemented in crane.lib. The respective attribute must be added to commonArgs (i.e. to both `buildDepsOnly` and `buildPackage` args).
1 parent 5904bf4 commit a8264df

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

zkvmLib.nix

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,24 @@ pkgs: guest: let
7676
'';
7777
};
7878

79-
cargoVendorDir = craneLib.vendorCargoDeps {
80-
src = cargoLockDrv;
81-
};
79+
cargoVendorDir = craneLib.vendorCargoDeps ({
80+
src = cargoLockDrv;
81+
} // (
82+
if args ? overrideVendorCargoPackage then
83+
{ inherit (args) overrideVendorCargoPackage; }
84+
else
85+
{ })
86+
// (
87+
if args ? overrideVendorGitCheckout then
88+
{ inherit (args) overrideVendorGitCheckout; }
89+
else
90+
{ }));
91+
8292
};
8393
in {
8494
buildDepsOnly = craneLib: args: let
8595
cargoLocks = generateCargoLocks craneLib args;
86-
in craneLib.buildDepsOnly (cargoLocks // args // {
96+
in craneLib.buildDepsOnly (cargoLocks // (builtins.removeAttrs args ["overrideVendorCargoPackage" "overrideVendorGitCheckout"]) // {
8797
postUnpack = ''
8898
${args.postUnpack or ""}
8999
ln -s ../../../guests ./source/zkvms/${args.pname}/guest/
@@ -193,5 +203,5 @@ in {
193203
'';
194204

195205
doNotPostBuildInstallCargoBinaries = true;
196-
} // args // { inherit pname; });
206+
} // (builtins.removeAttrs args ["overrideVendorCargoPackage" "overrideVendorGitCheckout"]) // { inherit pname; });
197207
}

0 commit comments

Comments
 (0)