From cbdf482422f4fe02112f80f45499dbd70f3b5e0e Mon Sep 17 00:00:00 2001 From: alexion Date: Wed, 16 Sep 2026 14:50:19 -0400 Subject: [PATCH] refactor(dotfiles): order default let bindings --- docs/TODO.md | 3 ++- src/dotfiles/default.nix | 19 +++++++++---------- src/skills/nix-style/rules/let.md | 15 +++++++++++++++ 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/docs/TODO.md b/docs/TODO.md index daa860a..157d245 100644 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -18,6 +18,7 @@ - amazon / actualbudget exporter - vim-obsidian-markdown - dictionary cli tool +- repo-local Nix style linter - kitchen.md # migration @@ -107,7 +108,7 @@ Review Nix files in entrypoint order: - [x] `flake.nix` -- [ ] `src/dotfiles/default.nix` +- [x] `src/dotfiles/default.nix` - [ ] `src/dotfiles/util.nix` - [ ] `src/dotfiles/formatter.nix` - [ ] `src/dotfiles/apps.nix` diff --git a/src/dotfiles/default.nix b/src/dotfiles/default.nix index bfc653c..d012438 100644 --- a/src/dotfiles/default.nix +++ b/src/dotfiles/default.nix @@ -19,6 +19,15 @@ let root = root + "/modules"; }; + specialArgs = { + inherit + inputs + self + util + ; + registry = registry.collected; + }; + guestModules = import ./guests.nix { inherit inputs @@ -30,16 +39,6 @@ let repositoryModules = modules; root = root + "/guests"; }; - - specialArgs = { - inherit - inputs - self - util - ; - registry = registry.collected; - }; - in { formatter.${system} = diff --git a/src/skills/nix-style/rules/let.md b/src/skills/nix-style/rules/let.md index 1eff1d2..7012562 100644 --- a/src/skills/nix-style/rules/let.md +++ b/src/skills/nix-style/rules/let.md @@ -5,12 +5,27 @@ ### Rule Do not add a `let` binding only to let sibling values share one expression. +Apply this rule only when one sibling value clearly owns the concept. 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. +Do not apply this rule when a binding names a local constant used to keep sibling assignments in sync. ### Rationale Shared convenience bindings hide dependency direction. Explicit references show which value owns a concept and which value consumes it. +## Order `let` bindings by dependency + +### Rule + +Define a `let` binding before other bindings that reference it. +Use forward references only for intentional recursion or fixed-point wiring. + +### Rationale + +Nix permits recursive `let` bindings. +Top-down dependency order makes ordinary wiring easier to read. +This rule can become a linter rule because binding references are mechanically detectable. +