nix flake.lock is outdated
Describe the bug
I've cloned the leptos repo to create PR. If I run the cargo build using a nix shell specified by the flake Leptos's main brunch will not compile.
$ cargo build
Compiling unicode-ident v1.0.22
Compiling cfg-if v1.0.4
Compiling pin-project-lite v0.2.16
Compiling futures-core v0.3.31
Compiling memchr v2.7.6
Compiling bytes v1.11.0
Compiling futures-sink v0.3.31
Compiling log v0.4.29
Compiling once_cell v1.21.3
Compiling smallvec v1.15.1
Compiling itoa v1.0.17
Compiling pin-utils v0.1.0
Compiling futures-io v0.3.31
Compiling slab v0.4.11
Compiling futures-task v0.3.31
Compiling scopeguard v1.2.0
Compiling serde v1.0.228
Compiling unicode-segmentation v1.12.0
Compiling stable_deref_trait v1.2.1
Compiling equivalent v1.0.2
Compiling hashbrown v0.16.1
Compiling zerocopy v0.8.31
Compiling cpufeatures v0.2.17
Compiling percent-encoding v2.3.2
Compiling litemap v0.8.1
Compiling serde_core v1.0.228
Compiling writeable v0.6.2
Compiling serde_json v1.0.148
Compiling mime v0.3.17
Compiling or_poisoned v0.1.0 (/home/marek/Projekty/o-system/programowanie/rust/leptos/or_poisoned)
Compiling httpdate v1.0.3
Compiling local-waker v0.1.4
Compiling alloc-no-stdlib v2.0.4
Compiling regex-syntax v0.8.8
Compiling fnv v1.0.7
Compiling parking v2.2.1
Compiling bitflags v2.10.0
Compiling regex-lite v0.1.8
Compiling proc-macro2 v1.0.106
Compiling futures-channel v0.3.31
Compiling lock_api v0.4.14
Compiling encoding_rs v0.8.35
Compiling adler2 v2.0.1
Compiling tracing-core v0.1.36
Compiling simd-adler32 v0.3.8
Compiling powerfmt v0.2.0
Compiling num-conv v0.1.0
Compiling time-core v0.1.6
Compiling throw_error v0.3.1 (/home/marek/Projekty/o-system/programowanie/rust/leptos/any_error)
Compiling actix-service v2.0.3
Compiling libc v0.2.180
Compiling wasm-bindgen-shared v0.2.108
Compiling typenum v1.19.0
Compiling httparse v1.10.1
Compiling zmij v1.0.7
Compiling icu_properties_data v2.1.2
Compiling icu_normalizer_data v2.1.1
Compiling crossbeam-utils v0.8.21
Compiling form_urlencoded v1.2.2
Compiling alloc-stdlib v0.2.2
Compiling actix-utils v3.0.1
Compiling crc32fast v1.5.0
Compiling utf8_iter v1.0.4
Compiling tower-service v0.3.3
Compiling ryu v1.0.22
Compiling base64 v0.22.1
Compiling yansi v1.0.1
Compiling slotmap v1.1.1
Compiling reactive_graph v0.2.13 (/home/marek/Projekty/o-system/programowanie/rust/leptos/reactive_graph)
Compiling server_fn_macro v0.8.10 (/home/marek/Projekty/o-system/programowanie/rust/leptos/server_fn_macro)
Compiling local-channel v0.1.5
Compiling send_wrapper v0.6.0
Compiling tower-layer v0.3.3
Compiling xxhash-rust v0.8.15
Compiling either v1.15.0
Compiling foldhash v0.1.5
Compiling language-tags v0.3.2
error[E0425]: cannot find function `select_unpredictable` in module `hint`
--> /home/marek/.local/cargo/leptos/registry/src/index.crates.io-1949cf8c6b5b557f/zmij-1.0.7/src/lib.rs:621:28
|
621 | sig: hint::select_unpredictable(use_shorter, shorter, longer),
| ^^^^^^^^^^^^^^^^^^^^ not found in `hint`
|
help: consider importing this function
|
69 + use core::intrinsics::select_unpredictable;
|
help: if you import `select_unpredictable`, refer to it directly
|
621 - sig: hint::select_unpredictable(use_shorter, shorter, longer),
621 + sig: select_unpredictable(use_shorter, shorter, longer),
|
For more information about this error, try `rustc --explain E0425`.
Compiling http v1.4.0
Compiling convert_case v0.11.0
Compiling convert_case v0.10.0
Compiling http v0.2.12
Compiling deranged v0.5.5
Compiling brotli-decompressor v5.0.0
Compiling miniz_oxide v0.8.9
Compiling bytestring v1.5.0
Compiling time-macros v0.2.24
Compiling guardian v1.3.0
Compiling sync_wrapper v1.0.2
Compiling utf-8 v0.7.6
Compiling utf8-width v0.1.8
Compiling data-encoding v2.9.0
Compiling rustc-hash v2.1.1
Compiling impl-more v0.1.9
Compiling atomic-waker v1.1.2
error: could not compile `zmij` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...This error shows up, for some time already. Until now I was "solving" it using nix flake update and discarding flake.lock on commit.
To Reproduce
- Clone leptos repo from gihub
- Start nix shell
cargo build- See error
Possible solutions
Do nothing
nix flake update is not the end of the world and any nix user knows this command.
Simplest solution
Run nix flake update and submit PR with new flake.lock
| Pros | Cons |
|---|---|
| Simple | We will hit it again |
| It doesn't follow the rust nightly used in PR checks |
rust-toolchain.toml
oxalica/rust-overlay for nix has the ability to use rust-toolchain.toml file. Inside rust-toolchain.toml we can set specific version of rust nightly,
| Pros | Cons |
|---|---|
Many rust developers understand rust-toolchain.toml so you don't need to be nixpert to update that |
If we would use rust-toolchain.toml directly we would need to check if it interacts with GH actions, in worst case we would need to exclude the file from being imported |
| Easy to keep in sync with proper nightly version of the rust used by the PR checks | |
Many IDE's are capable of using rust-toolchain.toml |
Personally this is my favorite solution, since it makes it easiest to sync GH action rust version and flake one, even by leaving the comment in both files.
Bind specific nightly version in flake.nix
oxalica/rust-overlay supports setting up specific version of rust so version of rust can be set directly in the flake
| Pros | Cons |
|---|---|
| We can sync with proper nightly version of the rust used by the PR checks | Updating version requires editing the flake.nix which is not a Rust standard |
Next Steps
- Chose solution
- I'm will make a PR after we have an agreement
Source: leptos-rs/leptos