From a8264df8b851c60011f89295685d75f66291f28b Mon Sep 17 00:00:00 2001 From: Kamen Mladenov Date: Mon, 24 Feb 2025 15:24:56 +0200 Subject: 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). --- zkvmLib.nix | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'zkvmLib.nix') diff --git a/zkvmLib.nix b/zkvmLib.nix index bc7010b..cd92d5a 100644 --- a/zkvmLib.nix +++ b/zkvmLib.nix @@ -76,14 +76,24 @@ pkgs: guest: let ''; }; - cargoVendorDir = craneLib.vendorCargoDeps { - src = cargoLockDrv; - }; + cargoVendorDir = craneLib.vendorCargoDeps ({ + src = cargoLockDrv; + } // ( + if args ? overrideVendorCargoPackage then + { inherit (args) overrideVendorCargoPackage; } + else + { }) + // ( + if args ? overrideVendorGitCheckout then + { inherit (args) overrideVendorGitCheckout; } + else + { })); + }; in { buildDepsOnly = craneLib: args: let cargoLocks = generateCargoLocks craneLib args; - in craneLib.buildDepsOnly (cargoLocks // args // { + in craneLib.buildDepsOnly (cargoLocks // (builtins.removeAttrs args ["overrideVendorCargoPackage" "overrideVendorGitCheckout"]) // { postUnpack = '' ${args.postUnpack or ""} ln -s ../../../guests ./source/zkvms/${args.pname}/guest/ @@ -193,5 +203,5 @@ in { ''; doNotPostBuildInstallCargoBinaries = true; - } // args // { inherit pname; }); + } // (builtins.removeAttrs args ["overrideVendorCargoPackage" "overrideVendorGitCheckout"]) // { inherit pname; }); } -- cgit v1.2.3