From fe7d70ad78c4660e4e11f8c6bbcfca05fe1099ce Mon Sep 17 00:00:00 2001 From: Kamen Mladenov Date: Mon, 10 Mar 2025 15:28:32 +0200 Subject: feat(flake.nix): Add script for updating all zkVM package dependencies All crates use the zkVM packages (from nix-blockchain-development) as cargo path dependencies. For each zkVM, they're found in the host, guest and wrapper crates. Since there are a lot of places to update, we're introducing a script which automates this. --- flake.nix | 1 + update-nix-dependencies.nix | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 update-nix-dependencies.nix diff --git a/flake.nix b/flake.nix index 903acb4..21e9694 100644 --- a/flake.nix +++ b/flake.nix @@ -75,6 +75,7 @@ in { packages.${system} = hostPackages // guestPackages // { rust-format-all = callPackage ./rust-format-all.nix { }; + update-nix-dependencies = callPackage ./update-nix-dependencies.nix { }; }; formatter.${system} = pkgs.nixfmt; diff --git a/update-nix-dependencies.nix b/update-nix-dependencies.nix new file mode 100644 index 0000000..e3e4275 --- /dev/null +++ b/update-nix-dependencies.nix @@ -0,0 +1,37 @@ +{ writeShellApplication, cargo, }: +writeShellApplication { + name = "update_nix_dependencies"; + + runtimeInputs = [ cargo ]; + + text = '' + updateCrate() { + sed -i "s|/nix/store/[^-]\+-$1-[^/]\+|$2|" Cargo.toml + } + + cd zkvms + for zkvm in * + do + [ ! -d "$zkvm" ] || [ "$zkvm" == 'result' ] && continue + [ "$zkvm" == 'zkwasm' ] && continue + 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 ../guest + cargo generate-lockfile + cd ../host + cargo generate-lockfile + + popd + done + ''; +} -- cgit v1.2.3