From 230defc3f58161234f8752e98ecf11725c85860d Mon Sep 17 00:00:00 2001 From: Kamen Mladenov Date: Mon, 14 Apr 2025 09:45:51 +0300 Subject: feat(update-nix-dependencies): Use flake's nix-blockchain-development instead of default To get the new Nix outPaths for all zkVMs, we used to execute a `nix run` command, which found the paths from the nix-blockchain-development repo, default branch on latest commit. Since that could differ from what repo our flake actually uses, we're updating the logic. --- flake.nix | 7 +++++-- update-nix-dependencies.nix | 38 ++++++++++++++++++++++---------------- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/flake.nix b/flake.nix index b815571..ab5fadd 100644 --- a/flake.nix +++ b/flake.nix @@ -74,8 +74,11 @@ }) { } guests; in { packages.${system} = hostPackages // guestPackages // { - rust-format-all = callPackage ./rust-format-all.nix { }; - update-nix-dependencies = callPackage ./update-nix-dependencies.nix { }; + rust-format-all = callPackage ./rust-format-all.nix { + }; + update-nix-dependencies = callPackage ./update-nix-dependencies.nix { + zkvms = builtins.map (name: mcl-blockchain.packages.${system}.${name}) zkvms; + }; }; formatter.${system} = pkgs.nixfmt; diff --git a/update-nix-dependencies.nix b/update-nix-dependencies.nix index e3e4275..77b38af 100644 --- a/update-nix-dependencies.nix +++ b/update-nix-dependencies.nix @@ -1,35 +1,41 @@ -{ writeShellApplication, cargo, }: +{ writeShellApplication, cargo, zkvms, }: writeShellApplication { name = "update_nix_dependencies"; runtimeInputs = [ cargo ]; - text = '' - updateCrate() { + text = let + namesAndPaths = builtins.concatStringsSep + " " + (builtins.map + (zkvm: zkvm.pname + "," + zkvm.outPath) + zkvms); + in '' + updatePath() { sed -i "s|/nix/store/[^-]\+-$1-[^/]\+|$2|" Cargo.toml } + updateDep() { + updatePath "$1" "$2" + cargo generate-lockfile + } cd zkvms - for zkvm in * + for i in ${namesAndPaths} do - [ ! -d "$zkvm" ] || [ "$zkvm" == 'result' ] && continue - [ "$zkvm" == 'zkwasm' ] && continue + IFS=',' read -r zkvm path <<< "''${i}" + [ "$zkvm" == 'zkWasm' ] && continue + [ "$zkvm" == 'Nexus-zkVM' ] && zkvm=nexus + pushd "$zkvm" - newPath="$(nix build github:metacraft-labs/nix-blockchain-development#"$zkvm" --print-out-paths)" [ "$zkvm" == 'nexus' ] && zkvm=Nexus - cd guest - updateCrate "$zkvm" "$newPath" - cd ../host - updateCrate "$zkvm" "$newPath" - cd ../wrapper_macro - updateCrate "$zkvm" "$newPath" - + cd wrapper_macro + updatePath "$zkvm" "$path" cd ../guest - cargo generate-lockfile + updateDep "$zkvm" "$path" cd ../host - cargo generate-lockfile + updateDep "$zkvm" "$path" popd done -- cgit v1.2.3