Ldd error "Bad section type" on trying to build rust's wasm-pack hello world example

Using the ‘nightly’ version of rustc get me back to one of the first errors i had:

[INFO]: Checking for the Wasm target... Error: wasm32-unknown-unknown target not found in sysroot: "/nix/store/3h59wdgdz5pmkhnscj30rwyqscqfx07n-rust-1.45.2-2020-07-31-d3fb005a3"

Used rustc from the following path: "/home/oliver/.nix-profile/bin/rustc" It looks like Rustup is not being used. For non-Rustup setups, the wasm32-unknown-unknown target needs to be installed manually. See https://rustwasm.github.io/wasm-pack/book/prerequisites/non-rustup-setups.html on how to do this.

I couldn’t work out how to follow the instructions there (i.e., even get as far as the person in this thread ), hence my original shell.nix file.

ETA: the problem is in copying the downloaded rust-std-1.45.2-wasm32-unknown-unknown into rustc’s libs directory, because obviously that wants to be generated declaratively and i don’t know how:

cp: can't create directory '/nix/store/3h59wdgdz5pmkhnscj30rwyqscqfx07n-rust-1.45.2-2020-07-31-d3fb005a3/lib/rustlib/wasm32-unknown-unknown': Read-only file system