An easy-to-host PDS on the ATProtocol, MacOS. Grandma-approved.

feat(MM-64): add Nix flake + devenv development shell #2

merged opened by malpercio.dev targeting main from MM-64

Summary#

  • Adds flake.nix, devenv.nix, rust-toolchain.toml, and .envrc to provide a reproducible Nix-based dev shell via devenv
  • Pins the Rust stable toolchain with rustfmt, clippy, and rust-analyzer; includes just, cargo-audit, sqlite, and pkg-config as shell packages
  • Generates and commits flake.lock after verifying all 14 automatable acceptance criteria pass on macOS (aarch64-darwin)

Notes#

nix develop requires --impure --accept-flake-config due to devenv's need to read $PWD at evaluation time. The rust-overlay input was added as an explicit flake input (devenv's languages.rust module requires it directly when using toolchainFile).

Test Plan#

  • nix develop --impure --accept-flake-config activates shell on macOS
  • rustc --version → stable (1.94.0), cargo, rust-analyzer, clippy, rustfmt, just, cargo-audit, sqlite3, pkg-config --libs sqlite3 all verified
  • flake.lock committed and tracked by git
  • flake.nix has no packages or nixosModules outputs
  • Linux (x86_64-linux) verification — needs CI or contributor on Linux
  • rustup show reads rust-toolchain.toml without Nix
  • direnv allow activates shell automatically on cd

Full human test plan: docs/test-plans/2026-03-07-MM-64.md

Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:web:malpercio.dev/sh.tangled.repo.pull/3mgjf5myesb22
+10 -7
Interdiff #0 #1
.envrc

This file has not been changed.

.gitignore

This file has not been changed.

+4 -2
CLAUDE.md
··· 9 - Task Runner: just 10 11 ## Commands 12 - - `nix develop --impure --accept-flake-config` - Enter dev shell (flags required; devenv needs --impure for CWD detection) 13 - `cargo build` - Build all crates 14 - `cargo test` - Run all tests 15 - `cargo clippy` - Lint ··· 19 - Managed entirely by Nix flake + devenv; do not install tools globally 20 - direnv auto-activates via `.envrc` (`use flake`) 21 - Rust toolchain pinned in `rust-toolchain.toml` (stable, with rustfmt + clippy + rust-analyzer) 22 - - Shell provides: just, cargo-audit, sqlite, pkg-config 23 - `LIBSQLITE3_SYS_USE_PKG_CONFIG=1` is set automatically by devenv 24 25 ## Project Structure 26 - `crates/relay/` - Web relay (axum-based)
··· 9 - Task Runner: just 10 11 ## Commands 12 + - `nix develop --impure --accept-flake-config` - Enter dev shell (flags required; --impure for devenv CWD detection, --accept-flake-config activates the Cachix binary cache in nixConfig — without it, a cold build takes 20+ minutes) 13 - `cargo build` - Build all crates 14 - `cargo test` - Run all tests 15 - `cargo clippy` - Lint ··· 19 - Managed entirely by Nix flake + devenv; do not install tools globally 20 - direnv auto-activates via `.envrc` (`use flake`) 21 - Rust toolchain pinned in `rust-toolchain.toml` (stable, with rustfmt + clippy + rust-analyzer) 22 + - Shell provides: just, cargo-audit, sqlite (runtime binary + dev headers/library for rusqlite), pkg-config 23 - `LIBSQLITE3_SYS_USE_PKG_CONFIG=1` is set automatically by devenv 24 + - Binary cache: devenv.cachix.org (activated by `--accept-flake-config`); speeds up cold shell builds significantly 25 + - nixpkgs pin: `cachix/devenv-nixpkgs/rolling` (devenv's own nixpkgs fork — package versions may differ from upstream nixpkgs.search.dev) 26 27 ## Project Structure 28 - `crates/relay/` - Web relay (axum-based)
+1 -1
devenv.nix
··· 1 - { pkgs, lib, config, ... }: 2 { 3 languages.rust = { 4 enable = true;
··· 1 + { pkgs, ... }: 2 { 3 languages.rust = { 4 enable = true;
docs/design-plans/2026-03-07-MM-64.md

This file has not been changed.

+4 -3
docs/test-plans/2026-03-07-MM-64.md
··· 29 | 1.3 | Open `rust-toolchain.toml` | Contains `channel = "stable"` and `components = ["rustfmt", "clippy", "rust-analyzer"]`. | 30 | 1.4 | Open `devenv.nix` | Contains `languages.rust.enable = true`, `toolchainFile = ./rust-toolchain.toml`, and packages list with `just`, `cargo-audit`, `sqlite`, `pkg-config`. Also sets `LIBSQLITE3_SYS_USE_PKG_CONFIG = "1"`. | 31 | 1.5 | Open `.envrc` | Contains exactly `use flake` (one line). | 32 - | 1.6 | Run `git status` from repo root | `.envrc`, `flake.nix`, `devenv.nix`, `rust-toolchain.toml`, `flake.lock`, `.gitignore` are all tracked (not untracked or modified). | 33 34 --- 35 ··· 38 | Step | Action | Expected | 39 |------|--------|----------| 40 | 2.1 | `nix develop --impure --command bash -c 'echo "shell activated"'` | Prints "shell activated" and exits with code 0. devenv task output may appear on stderr (normal). | 41 - | 2.2 | `nix develop --impure --command bash -c 'rustc --version'` | Prints `rustc 1.94.0 (...)` or a similar stable version. No "nightly" or "beta" in the output. | 42 - | 2.3 | `nix develop --impure --command bash -c 'cargo --version && rust-analyzer --version && cargo clippy --version && rustfmt --version && just --version && cargo audit --version'` | All six commands succeed (exit 0). Each prints a version string. | 43 | 2.4 | `nix develop --impure --command bash -c 'sqlite3 --version && pkg-config --libs sqlite3'` | sqlite3 prints a version (3.x.x). pkg-config prints `-L/nix/store/.../lib -lsqlite3`. Both succeed. | 44 | 2.5 | `nix develop --impure --command bash -c 'echo $LIBSQLITE3_SYS_USE_PKG_CONFIG'` | Prints `1`. | 45
··· 29 | 1.3 | Open `rust-toolchain.toml` | Contains `channel = "stable"` and `components = ["rustfmt", "clippy", "rust-analyzer"]`. | 30 | 1.4 | Open `devenv.nix` | Contains `languages.rust.enable = true`, `toolchainFile = ./rust-toolchain.toml`, and packages list with `just`, `cargo-audit`, `sqlite`, `pkg-config`. Also sets `LIBSQLITE3_SYS_USE_PKG_CONFIG = "1"`. | 31 | 1.5 | Open `.envrc` | Contains exactly `use flake` (one line). | 32 + | 1.6 | Run `git ls-files --error-unmatch .envrc flake.nix devenv.nix rust-toolchain.toml flake.lock .gitignore` from repo root | Command exits 0 (all six files are tracked by git). | 33 34 --- 35 ··· 38 | Step | Action | Expected | 39 |------|--------|----------| 40 | 2.1 | `nix develop --impure --command bash -c 'echo "shell activated"'` | Prints "shell activated" and exits with code 0. devenv task output may appear on stderr (normal). | 41 + | 2.2 | `nix develop --impure --command bash -c 'rustc --version'` | Prints a stable Rust version (e.g. `rustc 1.XX.0 (...)`). No "nightly" or "beta" in the output. | 42 + | 2.3 | `nix develop --impure --command bash -c 'cargo --version && rust-analyzer --version && cargo clippy --version && rustfmt --version && just --version && cargo-audit --version'` | All six commands succeed (exit 0). Each prints a version string. (`cargo-audit --version` — note the hyphen; the Cargo subcommand `cargo audit --version` doubles the name in output.) | 43 + | 2.6 | `nix develop --impure --command cargo check` | Cargo type-checks all workspace crates. Exit code 0. Confirms toolchain, sqlite3 headers, and pkg-config integrate correctly. | 44 | 2.4 | `nix develop --impure --command bash -c 'sqlite3 --version && pkg-config --libs sqlite3'` | sqlite3 prints a version (3.x.x). pkg-config prints `-L/nix/store/.../lib -lsqlite3`. Both succeed. | 45 | 2.5 | `nix develop --impure --command bash -c 'echo $LIBSQLITE3_SYS_USE_PKG_CONFIG'` | Prints `1`. | 46
flake.lock

This file has not been changed.

flake.nix

This file has not been changed.

+1 -1
rust-toolchain.toml
··· 1 [toolchain] 2 channel = "stable" 3 components = ["rustfmt", "clippy", "rust-analyzer"] 4 - targets = ["aarch64-apple-darwin", "x86_64-unknown-linux-gnu"]
··· 1 [toolchain] 2 channel = "stable" 3 components = ["rustfmt", "clippy", "rust-analyzer"] 4 + targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu"]

History

2 rounds 0 comments
sign up or login to add to the discussion
7 commits
expand
docs: add MM-64 design plan — Nix flake + devenv dev shell
chore(MM-64): add Nix flake + devenv dev shell configuration
fix(MM-64): add rust-overlay input and allow-import-from-derivation
chore(MM-64): commit generated flake.lock
docs: add root CLAUDE.md with project context for MM-64
docs: add test plan for MM-64 Nix flake + devenv dev shell
fix(MM-64): address PR review — targets, devenv.nix, CLAUDE.md, test plan
expand 0 comments
pull request successfully merged
6 commits
expand
docs: add MM-64 design plan — Nix flake + devenv dev shell
chore(MM-64): add Nix flake + devenv dev shell configuration
fix(MM-64): add rust-overlay input and allow-import-from-derivation
chore(MM-64): commit generated flake.lock
docs: add root CLAUDE.md with project context for MM-64
docs: add test plan for MM-64 Nix flake + devenv dev shell
expand 0 comments