nix-best-practiceslisted
Install: claude install-skill rokokol/nix-best-practices-skill
# nix-best-practices
Nix has a formatter that settles layout and two linters that settle the language's own antipatterns. What is left over is everything they cannot see: the scope an expression opens, where an option is declared against where it is read, whether a package says what it is, whether a lock describes a machine instead of a project. That residue is what this standard is, and the test for whether a line belongs in it is whether a tool already decides it
The second thing they cannot see is time. A derivation's hash, an input's copy, an option's path: each is correct on the machine that wrote it and wrong on the next one, or correct today and wrong after a rename upstream. Most of the rules below are about that gap rather than about taste
[`check-nix.sh`](check-nix.sh) beside this file is the mechanical half. It runs the three tools and adds what none of them reach, and on every run it plants one defect per check into fixtures it prints itself and requires each to be rejected for that defect's own reason
## Doing the work
- **Start a new file from `./check-nix.sh --template module`**, or `package`, or `flake` — each is the shape below already assembled, and each is what the checker proves itself against
- **End every change with `./check-nix.sh`**, from the repository root or with `-C DIR`; a repository that wires the checker into its `checks` output gets the same rules from `nix flake check`, minus the two that need the flake's inputs
- **Ask `./check-nix.sh -