From 6552204f97af57afc861637b4da848642fbb78b9 Mon Sep 17 00:00:00 2001 From: Kamen Mladenov Date: Tue, 28 Jan 2025 16:39:43 +0200 Subject: feat(flake): Add zkvm with guest implementation packages Now, you have zkvm/guest_implementation packages, where you'll build and run the zkVM with guest_implementation --- flake.nix | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/flake.nix b/flake.nix index 02a601a..942b49f 100644 --- a/flake.nix +++ b/flake.nix @@ -46,7 +46,7 @@ # Requirements: # - zkVM is inside zkvms/pname/ # - guest crate is located at zkvms/pname/guest and is named "guest" - withCustomPhases = currentPackage: let + withCustomPhases = guest: currentPackage: let hostBin = currentPackage.hostBin or ("host-" + currentPackage.pname); in with currentPackage; { phases = [ @@ -117,22 +117,34 @@ doNotPostBuildInstallCargoBinaries = true; } // currentPackage; + createPackages = guestName: let + guest = if guestName == null then "graph_coloring" else guestName; + postfix = if guestName == null then "" else "/" + guest; - args-zkVM = { - craneLib-default = crane.mkLib pkgs; - zkVM-helpers = { - inherit fixDeps; - inherit withCustomPhases; + args-zkVM = { + craneLib-default = crane.mkLib pkgs; + zkVM-helpers = { + inherit fixDeps; + withCustomPhases = withCustomPhases guest; + }; }; + in { + "risc0${postfix}" = callPackage ./zkvms/risc0/default.nix args-zkVM; + "sp1${postfix}" = callPackage ./zkvms/sp1/default.nix args-zkVM; + "zkwasm${postfix}" = callPackage ./zkvms/zkwasm/default.nix args-zkVM; + "zkm${postfix}" = callPackage ./zkvms/zkm/default.nix args-zkVM; + "jolt${postfix}" = callPackage ./zkvms/jolt/default.nix args-zkVM; + "nexus${postfix}" = callPackage ./zkvms/nexus/default.nix args-zkVM; }; + + guests = [ null ] ++ (builtins.attrNames + (pkgs.lib.filterAttrs + (_: type: type == "directory") + (builtins.readDir ./guests))); in { - packages.${system} = { - risc0 = callPackage ./zkvms/risc0/default.nix args-zkVM; - sp1 = callPackage ./zkvms/sp1/default.nix args-zkVM; - zkwasm = callPackage ./zkvms/zkwasm/default.nix args-zkVM; - zkm = callPackage ./zkvms/zkm/default.nix args-zkVM; - jolt = callPackage ./zkvms/jolt/default.nix args-zkVM; - nexus = callPackage ./zkvms/nexus/default.nix args-zkVM; - }; + packages.${system} = pkgs.lib.foldr + (guest: accum: accum // (createPackages guest)) + {} + guests; }; } -- cgit v1.2.3