chore(devshell): add a Nix flake dev environment - #409
Conversation
nix develop provides stable + nightly Rust via rustup proxies linked to pinned rust-overlay store paths, plus node/yarn/bun, wasm-pack, binaryen, cargo-deny, git, pkg-config. Committed flake.lock pins nixpkgs and rust-overlay for reproducibility. Toolchains are symlinked under the official channel directory names in RUSTUP_HOME instead of custom names: rustup >= 1.28 rejects channel-like custom names, and rustup resolves +stable/+nightly as named channels in any case, so this is the only way those dispatch to the pinned store paths without network downloads. Manifest-dependent introspection (rustup show, rustup target list --toolchain <channel>) errors on read-only store-linked toolchains; use rustup toolchain list / rustc +<channel> --version instead.
|
Generally speaking unless the core maintainers and team around it are all using nix, I am generally in favor of not introducing bloat. I'll let the team input their thoughts: @pgherveou @filvecchiato @valentinfernandez1 @decrypto21 @Imod7 @eugypalu |
Its more for agents than anything else. i should be able to spawn a Podman Quadlet and automatically get the necessary dependencies installed without having it prebaked in the container for any agent to just go at it. If not nix the any other alternative makes sense. |
Summary
nix developnow drops you into a reproducible TrUAPI dev shell with the exact toolchain versions the repo needs — no ad-hoc rustup installs. The flake pins nixpkgs (nixos-unstable) and supplies stable + nightly Rust via rust-overlay, with the stable toolchain carrying thewasm32-unknown-unknowntarget. The shell also provides nodejs 22, yarn, bun, wasm-pack, wasm-bindgen-cli, binaryen, pkg-config, and cargo-deny.Toolchains are pinned as flake inputs rather than resolved by rustup, so every machine (and CI) gets identical compiler versions. The shell hook links the pinned store paths into
RUSTUP_HOME/toolchainsunder the channel names, socargo +stable/cargo +nightlykeep working and dispatch to the pinned toolchains instead of triggering a network download. Known tradeoff: linked toolchains carry no dist manifest, so manifest-dependent introspection (rustup show,rustup target list --toolchain <channel>) errors;rustup toolchain list,rustup show active-toolchain, andrustc +<channel> --versionare unaffected.Validation
nix flake check --no-buildpasses — the flake evaluates cleanly. Toolchain store builds were not realized in this run;nix developshould be exercised in CI before merge.flake.lockis committed, pinning nixpkgs, rust-overlay, and flake-utils revisions.New concepts
rust-overlay toolchains dispatched through rustup links
rustup normally downloads toolchains on demand; a flake wants them pinned in the Nix store.
rust-overlayprovides the pinned toolchains as derivations, butcargo +stable/cargo +nightlydispatch resolves through rustup'sRUSTUP_HOME/toolchains/<channel>-<triple>directories — a path rustup manages and would happily replace with its own download. The shell hook bridges the two: it symlinks the store paths into those channel directories before rustup can interfere. Use this when a repo needs channel-style dispatch (+stable,+nightly) against hermetic toolchains; skip it when the repo is fine calling the toolchain binaries directly or managing versions through rustup alone.