|
1 | 1 | { |
| 2 | + lib, |
2 | 3 | risc0-rust, |
3 | 4 | rustFromToolchainFile, |
4 | 5 | craneLib, |
|
16 | 17 | # https://github.com/risc0/risc0/blob/main/risc0/circuit/recursion/build.rs |
17 | 18 | recursion-zkr = |
18 | 19 | let |
19 | | - hash' = "1b80b77894fbd489262e327478d02e83262c4bf189b0873fda3f0c85cdbfc8d1"; |
| 20 | + hash = "744b999f0a35b3c86753311c7efb2a0054be21727095cf105af6ee7d3f4d8849"; |
20 | 21 | 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 | + }; |
24 | 29 | }; |
25 | 30 |
|
26 | 31 | commonArgs = rec { |
27 | 32 | pname = "risc0"; |
28 | | - version = "unstable-2025-03-12"; |
| 33 | + version = "3.0.3"; |
29 | 34 |
|
30 | 35 | nativeBuildInputs = [ |
31 | 36 | autoPatchelfHook |
|
37 | 42 | src = fetchFromGitHub { |
38 | 43 | owner = "risc0"; |
39 | 44 | repo = "risc0"; |
40 | | - rev = "2db67acadc4e1283f08993b5dcfcfc7afba6bbbd"; |
41 | | - hash = "sha256-eMFoz821x2NjibbTPF/i6rqRbqZ4g6njVDHc/udIDnA="; |
| 45 | + rev = "v${version}"; |
| 46 | + hash = "sha256-39vVvvGcWbQOBm8G08GvjpSklMCjcGNq2+UabfU1+gs="; |
42 | 47 | }; |
43 | 48 | }; |
44 | 49 |
|
45 | 50 | rust-toolchain = rustFromToolchainFile { |
46 | 51 | dir = commonArgs.src; |
47 | | - sha256 = "sha256-s1RPtyvDGJaX/BisLT+ifVfuhDT1nZkZ1NcK8sbwELM="; |
| 52 | + sha256 = "sha256-+9FmLhAOezBZCOziO0Qct1NOrfpjNsXxc/8I0c7BdKE="; |
48 | 53 | }; |
49 | 54 | crane = craneLib.overrideToolchain rust-toolchain; |
50 | 55 | cargoArtifacts = crane.buildDepsOnly commonArgs; |
51 | 56 | in |
52 | 57 | crane.buildPackage ( |
53 | 58 | commonArgs |
54 | 59 | // (installSourceAndCargo rust-toolchain) |
55 | | - // rec { |
| 60 | + // { |
56 | 61 | inherit cargoArtifacts; |
57 | 62 |
|
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 | + |
62 | 77 | # 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 | + ]; |
66 | 84 |
|
67 | 85 | 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" |
69 | 88 | ''; |
70 | 89 |
|
71 | 90 | cargoBuildCommand = "cargo build --release -p risc0-zkvm -p risc0-build -p cargo-risczero --features unstable"; |
|
0 commit comments