TLDR
How can naersk
be used with stable rust?
The gory details
I have created a toy repository by doing little (if anything) more than
cargo init
- Copy and paste the example from the bottom of the
naersk
repo. - Adjust the
sha256
This works[*], as can be seen by trying (in a flakes-enabled Nix)
nix shell github:jacg/naersk-test-drive/nightly -c naersk-test-drive
which prints a well-known friendly message.
Switching the rust toolchain from nightly to 1.50.0 like this
- channel = "nightly";
- sha256 = "sha256-hTj47PwUeP276uF6+HLDzsHYoDvfJa+y9o+vmxZqV0g=";
+ channel = "1.50.0";
+ sha256 = "sha256-PkX/nhR3RAi+c7W6bbphN3QbFcStg49hPEOYfvG51lA=";
and attempting the equivalent
nix shell github:jacg/naersk-test-drive/stable-1.50.0 -c naersk-test-drive
results in the following failure
error: --- Error --- nix-daemon
builder for '/nix/store/3ss36ngs5250w5clnmjil3xrpslz2h2i-naersk-test-drive-deps-0.1.0.drv' failed with exit code 101; last 10 log lines:
[naersk] cargo_build_output_json (created): /build/tmp.FLuJtRxLLj
[naersk] crate_sources: /nix/store/dxg5jxai9kzgzq1jwxxar53ymggi2w2j-crates-io
[naersk] RUSTFLAGS:
[naersk] CARGO_BUILD_RUSTFLAGS:
[naersk] CARGO_BUILD_RUSTFLAGS (updated): --remap-path-prefix /nix/store/dxg5jxai9kzgzq1jwxxar53ymggi2w2j-crates-io=/sources
building
cargo -Z unstable-options build $cargo_release -j "$NIX_BUILD_CORES" --out-dir out --message-format=$cargo_message_format
error: the `-Z` flag is only accepted on the nightly channel of Cargo, but this is the `stable` channel
See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information about Rust release channels.
[naersk] cargo returned with exit code 101, exiting
error: --- Error ------------------------------------------------------------------------------------------------------------------- nix
1 dependencies of derivation '/nix/store/9f2zzdrg1hlwxidic5q2csvdsrdna6jm-naersk-test-drive-0.1.0.drv' failed to build
On the one hand, the error contains
cargo -Z unstable-options build $cargo_release -j "$NIX_BUILD_CORES" --out-dir out --message-format=$cargo_message_format
error: the `-Z` flag is only accepted on the nightly channel of Cargo, but this is the `stable` channel
on the other, the naersk
documentation states that
Note: naersk relies on the --out-dir out option
which is an unstable option. This seems to imply that naersk
can only be used with unstable channels, however @jtojnar suggests here that naersk
should be usable with stable rust.
How can this example be adapted to work with stable rust?
Excruciatingly slow rust installation time
[*] On my machine, Nix takes around 17 minutes to install a version of the rust toolchain that I havenât used before. Most of which seems to be spent on copying an almost infinite number of Rust HTML doc files into the Nix store. This doesnât feel right, and I donât recall it being this slow before I started experimenting with flakes.