docs(nixos): add runnable direnv + flake dev-shell examples#71
Open
GregHilston wants to merge 1 commit into
Open
docs(nixos): add runnable direnv + flake dev-shell examples#71GregHilston wants to merge 1 commit into
GregHilston wants to merge 1 commit into
Conversation
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
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.
What & why
nixos/README.mdalready teaches our per-project dev-environment workflow —direnv+nix-direnv+ a flakedevShell, no Docker — but only as inlinecat > flake.nix <<EOFheredocs pinned toaarch64-linux. Nothing you can actuallycdinto 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/:README.md.gitignore.direnv/,__pycache__/,*.pyc,node_modules/, compiledhello.jspython-devshell/flake.nix(Python 3 +requests+ruff),.envrc(use flake),hello.pytypescript-devshell/flake.nix(Node.js 22 +typescript),.envrc(use flake),hello.tsBoth 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 toexamples/added in the "Per-Project Development Environments" section (existing heredocs left in place).nixos/CLAUDE.md— one bullet under "File Locations".Notes
flake.lock. The firstdirenv allow/nix developgenerates one; the example README explains that a real project would commit it for byte-for-byte reproducibility.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):flake.lockfor each example so contributors get a byte-for-byte identical toolchain:cd nixos/examples/python-devshell && nix develop -c python hello.py, andcd nixos/examples/typescript-devshell && nix develop -c bash -c 'tsc hello.ts && node hello.js'.fmtCI check (treefmt / alejandra) is green. If it flags the example flakes, runnix fmt nixos/and commit — formatting couldn't be verified locally withoutnix.direnv allowin each example dir to confirm auto-load-on-cd/ unload-on-leave.Verification (done in-session)
python -m py_compile hello.pypasses; 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