Skip to content

Commit 99267b0

Browse files
committed
feat(packages/risc0): Update
1 parent 25aebd6 commit 99267b0

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

packages/risc0/default.nix

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
lib,
23
risc0-rust,
34
rustFromToolchainFile,
45
craneLib,
@@ -56,20 +57,34 @@ in
5657
crane.buildPackage (
5758
commonArgs
5859
// (installSourceAndCargo rust-toolchain)
59-
// rec {
60+
// {
6061
inherit cargoArtifacts;
6162

62-
postPatch = ''
63-
# Replace usages of `Command::new("rustup")` with the correct value
64-
# which should be used
65-
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+
6677
# Fix starter template
67-
sed -i 's|{{ risc0_build }}|path = "'$out'"|' risc0/cargo-risczero/templates/rust-starter/methods/Cargo-toml
68-
sed -i 's|{{ risc0_zkvm }}|path = "'$out'"|' risc0/cargo-risczero/templates/rust-starter/host/Cargo-toml
69-
'';
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+
];
7084

7185
preBuild = ''
72-
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"
7388
'';
7489

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

0 commit comments

Comments
 (0)