Skip to content

chore(devshell): add a Nix flake dev environment - #409

Open
ryanleecode wants to merge 2 commits into
mainfrom
flake-nix
Open

chore(devshell): add a Nix flake dev environment#409
ryanleecode wants to merge 2 commits into
mainfrom
flake-nix

Conversation

@ryanleecode

Copy link
Copy Markdown

Summary

nix develop now 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 the wasm32-unknown-unknown target. 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/toolchains under the channel names, so cargo +stable / cargo +nightly keep 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, and rustc +<channel> --version are unaffected.

Validation

  • nix flake check --no-build passes — the flake evaluates cleanly. Toolchain store builds were not realized in this run; nix develop should be exercised in CI before merge.
  • flake.lock is 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-overlay provides the pinned toolchains as derivations, but cargo +stable / cargo +nightly dispatch resolves through rustup's RUSTUP_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.

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.
@ryanleecode
ryanleecode requested a review from a team August 14, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant