← ClaudeAtlas

nix-best-practiceslisted

A standard for Nix: the scope a with opens, the shape of a module header and where its options live, what a derivation's meta has to say, what a flake.lock must not hold — everything nixfmt, statix and deadnix cannot see and therefore has to be written down — plus check-nix.sh, a travelling checker that holds a tree to it and proves each of its own checks able to fail. Use when writing, reviewing or refactoring Nix: a NixOS or Home Manager module, a package, an overlay, a flake; when deciding where an option or an overlay belongs; when reading a statix or deadnix finding; or when a formatter and the code disagree. Triggers: nix, nixos, flake, flake.lock, nixpkgs, home-manager, mkOption, mkIf, overlay, derivation, mkDerivation, meta, callPackage, nixfmt, statix, deadnix, with pkgs, with lib, inherit, default.nix, useGlobalPkgs, напиши модуль, поправь флейк, добавь опцию, добавь пакет, оверлей, деривация, проверь nix, отформатируй nix, почему пересобирается
rokokol/nix-best-practices-skill · ★ 0 · Code & Development · score 75
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 -