wasix-org / cargo-wasix

Cargo wrapper for working with Webassembly wasi(x).
Apache License 2.0
52 stars 10 forks source link

Rustup doesn't work on NixOS when downloading `wasix` #22

Open knarkzel opened 1 year ago

knarkzel commented 1 year ago

The first reason is that rustc will already point to the system installed Rust:

~/.rustup/toolchains ❯ command -v rustc
/etc/profiles/per-user/odd/bin/rustc
~/.rustup/toolchains ❯ rustc +wasix --print sysroot
error: couldn't read +wasix: No such file or directory (os error 2)

The second reason is that the downloaded files such as rustc and rustdoc needs to be patched with patchelf, otherwise they won't run due to assuming paths for dependencies:

toolchains/wasix/bin ❯ pwd
/home/odd/.rustup/toolchains/wasix/bin
toolchains/wasix/bin ❯ ls
rustc  rustdoc
toolchains/wasix/bin ❯ ./rustc
bash: ./rustc: cannot execute: required file not found

Nix stores these dependencies in /nix/store, which is why they need patching.