Skip to content

Commit 8cc5296

Browse files
committed
feat(pkgs/risc0): Update unstable-2025-03-12 -> v3.0.3
1 parent 74a56b0 commit 8cc5296

File tree

1 file changed

+36
-17
lines changed

1 file changed

+36
-17
lines changed

packages/risc0/default.nix

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
lib,
23
risc0-rust,
34
rustFromToolchainFile,
45
craneLib,
@@ -16,16 +17,20 @@ let
1617
# https://github.com/risc0/risc0/blob/main/risc0/circuit/recursion/build.rs
1718
recursion-zkr =
1819
let
19-
hash' = "1b80b77894fbd489262e327478d02e83262c4bf189b0873fda3f0c85cdbfc8d1";
20+
hash = "744b999f0a35b3c86753311c7efb2a0054be21727095cf105af6ee7d3f4d8849";
2021
in
21-
fetchurl rec {
22-
url = "https://risc0-artifacts.s3.us-west-2.amazonaws.com/zkr/${hash'}.zip";
23-
hash = "sha256-G4C3eJT71IkmLjJ0eNAugyYsS/GJsIc/2j8Mhc2/yNE=";
22+
fetchurl {
23+
url = "https://risc0-artifacts.s3.us-west-2.amazonaws.com/zkr/${hash}.zip";
24+
hash = builtins.convertHash {
25+
inherit hash;
26+
toHashFormat = "sri";
27+
hashAlgo = "sha256";
28+
};
2429
};
2530

2631
commonArgs = rec {
2732
pname = "risc0";
28-
version = "unstable-2025-03-12";
33+
version = "3.0.3";
2934

3035
nativeBuildInputs = [
3136
autoPatchelfHook
@@ -37,35 +42,49 @@ let
3742
src = fetchFromGitHub {
3843
owner = "risc0";
3944
repo = "risc0";
40-
rev = "2db67acadc4e1283f08993b5dcfcfc7afba6bbbd";
41-
hash = "sha256-eMFoz821x2NjibbTPF/i6rqRbqZ4g6njVDHc/udIDnA=";
45+
rev = "v${version}";
46+
hash = "sha256-39vVvvGcWbQOBm8G08GvjpSklMCjcGNq2+UabfU1+gs=";
4247
};
4348
};
4449

4550
rust-toolchain = rustFromToolchainFile {
4651
dir = commonArgs.src;
47-
sha256 = "sha256-s1RPtyvDGJaX/BisLT+ifVfuhDT1nZkZ1NcK8sbwELM=";
52+
sha256 = "sha256-+9FmLhAOezBZCOziO0Qct1NOrfpjNsXxc/8I0c7BdKE=";
4853
};
4954
crane = craneLib.overrideToolchain rust-toolchain;
5055
cargoArtifacts = crane.buildDepsOnly commonArgs;
5156
in
5257
crane.buildPackage (
5358
commonArgs
5459
// (installSourceAndCargo rust-toolchain)
55-
// rec {
60+
// {
5661
inherit cargoArtifacts;
5762

58-
postPatch = ''
59-
# Replace usages of `Command::new("rustup")` with the correct value
60-
# which should be used
61-
sed -i '27d;28iPathBuf::from(r"${risc0-rust}")' rzup/src/paths.rs
63+
# NOTE: leave ability to change comments without modifying the bash code, avoiding unneeded rebuilds
64+
postPatch = lib.concatStringsSep "\n" [
65+
# Replace references to the normal installations of `rustup` and `risc0`
66+
# As per <https://github.com/risc0/risc0/blob/14b5d588dd01cf4f7ba804d8bb0a61264e6ae2c6/rzup/src/env.rs#L213>,
67+
# used in places like <https://github.com/risc0/risc0/blob/14b5d588dd01cf4f7ba804d8bb0a61264e6ae2c6/rzup/src/components.rs#L139>
68+
# bash
69+
''
70+
RISC0_PATHBUF='PathBuf::from(r#"'"${risc0-rust}"'"#)'
71+
sed -i \
72+
-e '215s|home_dir.join(".risc0")|'"$RISC0_PATHBUF"'|' \
73+
-e '219s|home_dir.join(".rustup")|'"$RISC0_PATHBUF"'|' \
74+
./rzup/src/env.rs
75+
''
76+
6277
# Fix starter template
63-
sed -i 's|{{ risc0_build }}|path = "'$out'"|' risc0/cargo-risczero/templates/rust-starter/methods/Cargo-toml
64-
sed -i 's|{{ risc0_zkvm }}|path = "'$out'"|' risc0/cargo-risczero/templates/rust-starter/host/Cargo-toml
65-
'';
78+
# bash
79+
''
80+
sed -i 's|{{ risc0_build }}|path = "'$out'"|' ./risc0/cargo-risczero/templates/rust-starter/methods/Cargo-toml
81+
sed -i 's|{{ risc0_zkvm }}|path = "'$out'"|' ./risc0/cargo-risczero/templates/rust-starter/host/Cargo-toml
82+
''
83+
];
6684

6785
preBuild = ''
68-
export RECURSION_SRC_PATH="${recursion-zkr}" RUSTFLAGS="$RUSTFLAGS -A dead_code"
86+
export RECURSION_SRC_PATH="${recursion-zkr}"
87+
export RUSTFLAGS="$RUSTFLAGS -A dead_code"
6988
'';
7089

7190
cargoBuildCommand = "cargo build --release -p risc0-zkvm -p risc0-build -p cargo-risczero --features unstable";

0 commit comments

Comments
 (0)