Skip to content

Commit c02d489

Browse files
committed
feat(zkvmLib): Attribute for specifying a guest or host specific Rust toolchains
Allows the host and guest program toolchains to differ. Generally, you should only need to set one.
1 parent 97975be commit c02d489

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

zkvmLib.nix

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ in {
147147
buildGuestPhase = ''
148148
export INPUTS_DIR="$PWD/guests/${guest}"
149149
export ZKVM="${args.pname}" GUEST="${guest}"
150+
OLD_PATH="$PATH"
151+
152+
${if args ? guestToolchain then "export PATH=\"${args.guestToolchain}/bin:$PATH\"" else ""}
150153
151154
pushd zkvms/${args.pname}/guest
152155
runHook preBuildGuest
@@ -157,6 +160,7 @@ in {
157160
158161
${if args ? guestTarget then "ln -s ../../guest/target/${args.guestTarget}/release/guest ../host/src/guest" else ""}
159162
unset RUSTUP_TOOLCHAIN RUSTFLAGS CARGO_ENCODED_RUSTFLAGS
163+
export PATH="$OLD_PATH"
160164
161165
runHook postBuildGuest
162166
popd
@@ -165,13 +169,18 @@ in {
165169
buildPhase = ''
166170
export INPUTS_DIR="$PWD/guests/${guest}"
167171
export ZKVM="${args.pname}" GUEST="${guest}"
172+
OLD_PATH="$PATH"
173+
174+
${if args ? hostToolchain then "export PATH=\"${args.hostToolchain}/bin:$PATH\"" else ""}
168175
169176
pushd zkvms/${args.pname}/host
170177
runHook preBuild
171178
172179
cargo --version
173180
cargo build --release
174181
182+
export PATH="$OLD_PATH"
183+
175184
runHook postBuild
176185
popd
177186
'';

0 commit comments

Comments
 (0)