diff --git a/src/dotfiles/registry/collection.nix b/src/dotfiles/registry/collection.nix index b5de52d..83d08b7 100644 --- a/src/dotfiles/registry/collection.nix +++ b/src/dotfiles/registry/collection.nix @@ -5,21 +5,6 @@ validate, }: let - withOperations = - registry: - registry - // { - join = host: entry: join registry host entry; - }; - - join = - registry: host: entry: - lib.filterAttrs (_name: value: value != null) ( - lib.mapAttrs ( - registryName: _registry: (registry.${registryName}.${host} or { }).${entry} or null - ) definitions - ); - collectData = let data = lib.mapAttrs ( @@ -74,5 +59,16 @@ let rawDeclarations = registryName: lib.mapAttrs (_hostName: host: host.config.registry.${registryName} or { }) hosts; + + join = + registry: host: entry: + lib.filterAttrs (_name: value: value != null) ( + lib.mapAttrs ( + registryName: _registry: (registry.${registryName}.${host} or { }).${entry} or null + ) definitions + ); in -withOperations collectData +collectData +// { + join = host: entry: join collectData host entry; +} diff --git a/src/skills/style/nix/rules/let.md b/src/skills/style/nix/rules/let.md index 7a3d576..222e06a 100644 --- a/src/skills/style/nix/rules/let.md +++ b/src/skills/style/nix/rules/let.md @@ -15,3 +15,16 @@ Do not apply this rule when a binding names a local constant used to keep siblin Shared convenience bindings hide dependency direction. Explicit references show which value owns a concept and which value consumes it. + +## Do not use single-use merge wrappers + +### Rule + +Do not bind a local function that extends an attribute-set argument when it has one caller. +Merge the fields in the caller. +Keep the function when two or more callers use it. + +### Rationale + +Single-use wrappers hide construction of the result. +Direct merges show the added fields and their owner.