docs(skills): add nix let review rule #55
@@ -13,9 +13,19 @@ Do not report preferences unless a loaded rule states them.
|
|||||||
Use this format for each finding:
|
Use this format for each finding:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
`path:line`: Finding title.
|
`code-path:line`
|
||||||
|
> `smallest reviewed-code excerpt that shows the violation`
|
||||||
|
|
||||||
|
`rule-file:line`: Finding title.
|
||||||
Summary: why the code breaks the rule
|
Summary: why the code breaks the rule
|
||||||
Fix: suggested fix
|
Fix: suggested fix
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Keep the code excerpt to one to three lines when possible.
|
||||||
|
Use a longer excerpt only when the violation needs surrounding context.
|
||||||
|
Use `...` to omit unrelated lines from a multi-line excerpt.
|
||||||
|
Use a skill-relative rule citation, such as `let.md:7`.
|
||||||
|
Make the fix direct.
|
||||||
|
Do not include alternatives when one fix best follows the cited rule.
|
||||||
|
|
||||||
It is acceptable to report no findings when the reviewed Nix already follows the loaded rules.
|
It is acceptable to report no findings when the reviewed Nix already follows the loaded rules.
|
||||||
|
|||||||
203
docs/TODO.md
203
docs/TODO.md
@@ -103,120 +103,89 @@
|
|||||||
- centralize shared system group names, starting with the `storage` group
|
- centralize shared system group names, starting with the `storage` group
|
||||||
|
|
||||||
## nix refactor
|
## nix refactor
|
||||||
```text
|
|
||||||
nixos
|
Review Nix files in entrypoint order:
|
||||||
├── guests
|
|
||||||
│ ├── actualbudget.nix
|
- [x] `flake.nix`
|
||||||
│ ├── copyparty.nix
|
- [ ] `src/dotfiles/default.nix`
|
||||||
│ ├── reverse-proxy.nix
|
- [ ] `src/dotfiles/util.nix`
|
||||||
│ └── valheim.nix
|
- [ ] `src/dotfiles/formatter.nix`
|
||||||
├── hosts
|
- [ ] `src/dotfiles/apps.nix`
|
||||||
│ ├── neogaia
|
- [ ] `src/dotfiles/registry.nix`
|
||||||
│ │ ├── default.nix
|
- [ ] `configs/nixos/registry/address.nix`
|
||||||
│ │ ├── disk.nix
|
- [ ] `configs/nixos/registry/env-var.nix`
|
||||||
│ │ ├── hardware-configuration.nix
|
- [ ] `configs/nixos/registry/homepage.nix`
|
||||||
│ │ ├── ssh_host_ed25519_key.pub
|
- [ ] `configs/nixos/registry/route.nix`
|
||||||
│ │ └── ssh_host_rsa_key.pub
|
- [ ] `configs/nixos/registry/shell-shortcut.nix`
|
||||||
│ ├── pikachu
|
- [ ] `configs/nixos/registry/stable-uid.nix`
|
||||||
│ │ ├── default.nix
|
- [ ] `src/dotfiles/modules.nix`
|
||||||
│ │ ├── disk.nix
|
- [ ] `configs/nixos/modules/default.nix`
|
||||||
│ │ ├── hardware-configuration.nix
|
- [ ] `configs/nixos/modules/host.nix`
|
||||||
│ │ ├── ssh_host_ed25519_key.pub
|
- [ ] `configs/nixos/modules/guest.nix`
|
||||||
│ │ └── ssh_host_rsa_key.pub
|
- [ ] `configs/nixos/modules/monorepo.nix`
|
||||||
│ └── zeus
|
- [ ] `configs/nixos/modules/zfs.nix`
|
||||||
│ ├── default.nix
|
- [ ] `configs/nixos/modules/network/ssh.nix`
|
||||||
│ ├── disk.nix
|
- [ ] `configs/nixos/modules/network/vlans.nix`
|
||||||
│ ├── hardware-configuration.nix
|
- [ ] `configs/nixos/modules/network/vpn-client.nix`
|
||||||
│ ├── ssh_host_ed25519_key.pub
|
- [ ] `configs/nixos/modules/desktop/default.nix`
|
||||||
│ └── ssh_host_rsa_key.pub
|
- [ ] `configs/nixos/modules/desktop/apps/alacritty.nix`
|
||||||
├── modules
|
- [ ] `configs/nixos/modules/desktop/apps/firefox.nix`
|
||||||
│ ├── desktop
|
- [ ] `configs/nixos/modules/desktop/apps/ghostty.nix`
|
||||||
│ │ ├── apps
|
- [ ] `configs/nixos/modules/desktop/apps/obsidian.nix`
|
||||||
│ │ │ ├── alacritty.nix
|
- [ ] `configs/nixos/modules/desktop/apps/signal.nix`
|
||||||
│ │ │ ├── firefox.nix
|
- [ ] `configs/nixos/modules/desktop/apps/steam.nix`
|
||||||
│ │ │ ├── ghostty.nix
|
- [ ] `configs/nixos/modules/desktop/apps/vencord.nix`
|
||||||
│ │ │ ├── obsidian.nix
|
- [ ] `configs/nixos/modules/desktop/session/hyprland/default.nix`
|
||||||
│ │ │ ├── signal.nix
|
- [ ] `configs/nixos/modules/desktop/session/hyprland/hypridle.nix`
|
||||||
│ │ │ ├── steam.nix
|
- [ ] `configs/nixos/modules/desktop/session/hyprland/hyprlock.nix`
|
||||||
│ │ │ └── vencord.nix
|
- [ ] `configs/nixos/modules/desktop/session/login.nix`
|
||||||
│ │ ├── session
|
- [ ] `configs/nixos/modules/desktop/session/mako.nix`
|
||||||
│ │ │ ├── hyprland
|
- [ ] `configs/nixos/modules/desktop/session/portals.nix`
|
||||||
│ │ │ │ ├── default.nix
|
- [ ] `configs/nixos/modules/desktop/session/rofi.nix`
|
||||||
│ │ │ │ ├── hypridle.nix
|
- [ ] `configs/nixos/modules/desktop/session/waybar.nix`
|
||||||
│ │ │ │ └── hyprlock.nix
|
- [ ] `configs/nixos/modules/desktop/utilities/audio.nix`
|
||||||
│ │ │ ├── login.nix
|
- [ ] `configs/nixos/modules/desktop/utilities/clipboard.nix`
|
||||||
│ │ │ ├── mako.nix
|
- [ ] `configs/nixos/modules/desktop/utilities/osd.nix`
|
||||||
│ │ │ ├── portals.nix
|
- [ ] `configs/nixos/modules/desktop/utilities/recording.nix`
|
||||||
│ │ │ ├── rofi.nix
|
- [ ] `configs/nixos/modules/desktop/utilities/screenshot.nix`
|
||||||
│ │ │ └── waybar.nix
|
- [ ] `configs/nixos/modules/desktop/utilities/theming.nix`
|
||||||
│ │ ├── utilities
|
- [ ] `configs/nixos/modules/desktop/utilities/userdirs.nix`
|
||||||
│ │ │ ├── audio.nix
|
- [ ] `configs/nixos/modules/services/actualbudget.nix`
|
||||||
│ │ │ ├── clipboard.nix
|
- [ ] `configs/nixos/modules/services/copyparty.nix`
|
||||||
│ │ │ ├── osd.nix
|
- [ ] `configs/nixos/modules/services/homepage.nix`
|
||||||
│ │ │ ├── recording.nix
|
- [ ] `configs/nixos/modules/services/navidrome.nix`
|
||||||
│ │ │ ├── screenshot.nix
|
- [ ] `configs/nixos/modules/services/reverse-proxy.nix`
|
||||||
│ │ │ ├── theming.nix
|
- [ ] `configs/nixos/modules/services/steamcmd.nix`
|
||||||
│ │ │ └── userdirs.nix
|
- [ ] `configs/nixos/modules/services/games/palworld.nix`
|
||||||
│ │ └── default.nix
|
- [ ] `configs/nixos/modules/services/games/valheim.nix`
|
||||||
│ ├── network
|
- [ ] `configs/nixos/modules/shell/bazel.nix`
|
||||||
│ │ ├── ssh.nix
|
- [ ] `configs/nixos/modules/shell/direnv/default.nix`
|
||||||
│ │ ├── vlans.nix
|
- [ ] `configs/nixos/modules/shell/fish/default.nix`
|
||||||
│ │ └── vpn-client.nix
|
- [ ] `configs/nixos/modules/shell/gitea-axi.nix`
|
||||||
│ ├── services
|
- [ ] `configs/nixos/modules/shell/git.nix`
|
||||||
│ │ ├── games
|
- [ ] `configs/nixos/modules/shell/herdr.nix`
|
||||||
│ │ │ └── valheim.nix
|
- [ ] `configs/nixos/modules/shell/nvim/default.nix`
|
||||||
│ │ ├── actualbudget.nix
|
- [ ] `configs/nixos/modules/shell/omp.nix`
|
||||||
│ │ ├── copyparty.nix
|
- [ ] `configs/nixos/modules/shell/pi/default.nix`
|
||||||
│ │ ├── reverse-proxy.nix
|
- [ ] `configs/nixos/modules/shell/python.nix`
|
||||||
│ │ └── steamcmd.nix
|
- [ ] `configs/nixos/modules/shell/rust.nix`
|
||||||
│ ├── shell
|
- [ ] `configs/nixos/modules/shell/tmux/default.nix`
|
||||||
│ │ ├── direnv
|
- [ ] `configs/nixos/modules/shell/yazi.nix`
|
||||||
│ │ │ ├── default.nix
|
- [ ] `src/dotfiles/guests.nix`
|
||||||
│ │ │ └── repo-flake.sh
|
- [ ] `configs/nixos/guests/actualbudget.nix`
|
||||||
│ │ ├── fish
|
- [ ] `configs/nixos/guests/copyparty.nix`
|
||||||
│ │ │ ├── completions
|
- [ ] `configs/nixos/guests/homepage.nix`
|
||||||
│ │ │ │ └── bazel.fish
|
- [ ] `configs/nixos/guests/navidrome.nix`
|
||||||
│ │ │ ├── functions
|
- [ ] `configs/nixos/guests/palworld.nix`
|
||||||
│ │ │ │ ├── copy.fish
|
- [ ] `configs/nixos/guests/reverse-proxy.nix`
|
||||||
│ │ │ │ └── deploy-to.fish
|
- [ ] `configs/nixos/guests/valheim.nix`
|
||||||
│ │ │ ├── config.fish
|
- [ ] `src/dotfiles/hosts.nix`
|
||||||
│ │ │ └── default.nix
|
- [ ] `configs/nixos/hosts/neogaia/default.nix`
|
||||||
│ │ ├── nvim
|
- [ ] `configs/nixos/hosts/neogaia/disk.nix`
|
||||||
│ │ │ ├── config.lua
|
- [ ] `configs/nixos/hosts/neogaia/hardware-configuration.nix`
|
||||||
│ │ │ └── default.nix
|
- [ ] `configs/nixos/hosts/pikachu/default.nix`
|
||||||
│ │ ├── pi
|
- [ ] `configs/nixos/hosts/pikachu/disk.nix`
|
||||||
│ │ │ ├── patches
|
- [ ] `configs/nixos/hosts/pikachu/hardware-configuration.nix`
|
||||||
│ │ │ │ ├── pi-flex-spacer.patch
|
- [ ] `configs/nixos/hosts/zeus/default.nix`
|
||||||
│ │ │ │ ├── pi-project-resource-ancestors.patch
|
- [ ] `configs/nixos/hosts/zeus/disk.nix`
|
||||||
│ │ │ │ └── pi-tool-lookup-validation.patch
|
- [ ] `configs/nixos/hosts/zeus/hardware-configuration.nix`
|
||||||
│ │ │ └── default.nix
|
|
||||||
│ │ ├── tmux
|
|
||||||
│ │ │ ├── default.nix
|
|
||||||
│ │ │ └── extra.conf
|
|
||||||
│ │ ├── bazel.nix
|
|
||||||
│ │ ├── git.nix
|
|
||||||
│ │ ├── gitea-axi.nix
|
|
||||||
│ │ ├── herdr.nix
|
|
||||||
│ │ ├── python.nix
|
|
||||||
│ │ ├── rust.nix
|
|
||||||
│ │ └── yazi.nix
|
|
||||||
│ ├── default.nix
|
|
||||||
│ ├── guest.nix
|
|
||||||
│ ├── host.nix
|
|
||||||
│ ├── monorepo.nix
|
|
||||||
│ └── zfs.nix
|
|
||||||
├── registry
|
|
||||||
│ ├── address.nix
|
|
||||||
│ ├── env-var.nix
|
|
||||||
│ ├── route.nix
|
|
||||||
│ ├── shell-shortcut.nix
|
|
||||||
│ └── stable-uid.nix
|
|
||||||
├── secrets
|
|
||||||
│ ├── neogaia.yaml
|
|
||||||
│ ├── pikachu.yaml
|
|
||||||
│ ├── shared.yaml
|
|
||||||
│ └── zeus.yaml
|
|
||||||
├── .sops.yaml
|
|
||||||
├── AGENTS.md
|
|
||||||
└── README.md
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ in
|
|||||||
pkgs.writeShellApplication {
|
pkgs.writeShellApplication {
|
||||||
name = "fix";
|
name = "fix";
|
||||||
runtimeInputs = [
|
runtimeInputs = [
|
||||||
formatter.config.build.wrapper
|
formatter
|
||||||
pkgs.statix
|
pkgs.statix
|
||||||
pkgs.deadnix
|
pkgs.deadnix
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -40,20 +40,20 @@ let
|
|||||||
registry = registry.collected;
|
registry = registry.collected;
|
||||||
};
|
};
|
||||||
|
|
||||||
formatter = import ./formatter.nix {
|
|
||||||
inherit inputs system;
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
formatter.${system} = formatter.config.build.wrapper;
|
formatter.${system} =
|
||||||
|
(import ./formatter.nix {
|
||||||
|
inherit inputs system;
|
||||||
|
}).config.build.wrapper;
|
||||||
|
|
||||||
apps.${system} = import ./apps.nix {
|
apps.${system} = import ./apps.nix {
|
||||||
inherit
|
inherit
|
||||||
inputs
|
inputs
|
||||||
lib
|
lib
|
||||||
formatter
|
|
||||||
system
|
system
|
||||||
;
|
;
|
||||||
|
formatter = self.formatter.${system};
|
||||||
};
|
};
|
||||||
|
|
||||||
nixosConfigurations = import ./hosts.nix {
|
nixosConfigurations = import ./hosts.nix {
|
||||||
|
|||||||
@@ -9,12 +9,8 @@ Use this skill as the source of truth for repository Nix conventions.
|
|||||||
|
|
||||||
## Load rules
|
## Load rules
|
||||||
|
|
||||||
Read every Markdown file under [`rules/`](rules/) before applying this skill.
|
Read every Markdown file directly under [`rules/`](rules/) before applying this skill.
|
||||||
Discover rule files from the skill source:
|
Resolve [`rules/`](rules/) relative to this `SKILL.md`.
|
||||||
|
|
||||||
```bash
|
|
||||||
find src/skills/nix-style/rules -maxdepth 1 -type f -name '*.md' -print | sort
|
|
||||||
```
|
|
||||||
|
|
||||||
Finish when all discovered rule files have been read.
|
Finish when all discovered rule files have been read.
|
||||||
|
|
||||||
@@ -29,7 +25,8 @@ After editing Nix files, run:
|
|||||||
nix run .#fix
|
nix run .#fix
|
||||||
```
|
```
|
||||||
|
|
||||||
Finish when the Nix change follows the loaded rules.
|
Finish when `nix run .#fix` succeeds and the Nix change follows the loaded rules.
|
||||||
|
If the command fails, report the failure.
|
||||||
|
|
||||||
## Maintain rules
|
## Maintain rules
|
||||||
|
|
||||||
|
|||||||
16
src/skills/nix-style/rules/let.md
Normal file
16
src/skills/nix-style/rules/let.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# Let rules
|
||||||
|
|
||||||
|
## Prefer explicit dependencies over shared convenience bindings
|
||||||
|
|
||||||
|
### Rule
|
||||||
|
|
||||||
|
Do not add a `let` binding only to let sibling values share one expression.
|
||||||
|
When one sibling value owns the concept, reference that sibling value directly.
|
||||||
|
When a flake output owns the public value, reference that output through `self`.
|
||||||
|
Do not make an output attrset recursive only to reference sibling outputs.
|
||||||
|
|
||||||
|
### Rationale
|
||||||
|
|
||||||
|
Shared convenience bindings hide dependency direction.
|
||||||
|
Explicit references show which value owns a concept and which value consumes it.
|
||||||
|
|
||||||
Reference in New Issue
Block a user