Skip to content

docs(nixos): add runnable direnv + flake dev-shell examples#71

Open
GregHilston wants to merge 1 commit into
masterfrom
claude/dev-environment-tools-gn3db2
Open

docs(nixos): add runnable direnv + flake dev-shell examples#71
GregHilston wants to merge 1 commit into
masterfrom
claude/dev-environment-tools-gn3db2

Conversation

@GregHilston

@GregHilston GregHilston commented Jul 11, 2026

Copy link
Copy Markdown
Owner

What & why

nixos/README.md already teaches our per-project dev-environment workflow — direnv + nix-direnv + a flake devShell, no Docker — but only as inline cat > flake.nix <<EOF heredocs pinned to aarch64-linux. Nothing you can actually cd into and run.

This adds two copy-and-run example projects under a new nixos/examples/ so the workflow is demonstrated by a real directory, not a snippet.

Changes

New nixos/examples/:

File Purpose
README.md Brief explainer: how direnv + flakes work, and the exact commands to run
.gitignore Ignores .direnv/, __pycache__/, *.pyc, node_modules/, compiled hello.js
python-devshell/ flake.nix (Python 3 + requests + ruff), .envrc (use flake), hello.py
typescript-devshell/ flake.nix (Node.js 22 + typescript), .envrc (use flake), hello.ts

Both flakes use flake-utils.eachDefaultSystem, so they work on every host architecture with no edits — unlike the arch-pinned heredocs they complement.

Doc links (as requested):

  • nixos/README.md — a pointer to examples/ added in the "Per-Project Development Environments" section (existing heredocs left in place).
  • nixos/CLAUDE.md — one bullet under "File Locations".

Notes

  • No committed flake.lock. The first direnv allow / nix develop generates one; the example README explains that a real project would commit it for byte-for-byte reproducibility.
  • These are standalone flakes not referenced by the nixos flake, so nix flake check / the host dry-run builds never evaluate them — they're only text-formatted by treefmt.

Remaining / follow-up steps

These need a Nix host (this PR was authored in an environment without nix):

  • Commit flake.lock for each example so contributors get a byte-for-byte identical toolchain:
    cd nixos/examples/python-devshell     && nix flake lock
    cd ../typescript-devshell             && nix flake lock
    git add nixos/examples/*/flake.lock && git commit -m "chore(examples): pin flake.lock"
  • Verify each shell loads: cd nixos/examples/python-devshell && nix develop -c python hello.py, and cd nixos/examples/typescript-devshell && nix develop -c bash -c 'tsc hello.ts && node hello.js'.
  • Confirm the fmt CI check (treefmt / alejandra) is green. If it flags the example flakes, run nix fmt nixos/ and commit — formatting couldn't be verified locally without nix.
  • (Optional) direnv allow in each example dir to confirm auto-load-on-cd / unload-on-leave.

Verification (done in-session)

python -m py_compile hello.py passes; the flakes were hand-formatted to match the repo's alejandra style. Authoritative Nix checks are in the follow-up list above.

🤖 Generated with Claude Code

https://claude.ai/code/session_011XBAGAamSrYUHPoqXWL4rX

Add nixos/examples/ with two copy-and-run per-project dev environments
(python-devshell/, typescript-devshell/) that demonstrate the repo's
direnv + nix-direnv + flake devShell workflow. Each is just a flake.nix,
an `.envrc` (`use flake`), and a tiny hello program that proves the
toolchain loaded — no Docker.

The flakes use flake-utils.eachDefaultSystem so they work on every host
architecture with no edits, unlike the arch-pinned heredoc snippets they
complement. A shared README explains the workflow and exact commands.

Link the new examples from the "Per-Project Development Environments"
section of nixos/README.md and from nixos/CLAUDE.md's File Locations list.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011XBAGAamSrYUHPoqXWL4rX
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.

2 participants