chore(devshell): add a Nix flake dev environment - #409
Open
ryanleecode wants to merge 2 commits into
Open
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.