refactor(dotfiles): centralize Nix suffix removal

This commit is contained in:
2026-09-27 09:33:43 -04:00
parent 3b2d16743e
commit a854f40077
4 changed files with 15 additions and 3 deletions

View File

@@ -1,6 +1,5 @@
{
inputs,
lib,
root,
specialArgs,
repositoryModules,
@@ -276,7 +275,7 @@ let
};
};
names = map (path: lib.removeSuffix ".nix" (builtins.baseNameOf path)) files;
names = map (path: util.removeNixSuffix (builtins.baseNameOf path)) files;
in
{
imports = files ++ map mkGuest names;

View File

@@ -11,7 +11,7 @@ let
)
);
registryName = fileName: lib.removeSuffix ".nix" fileName;
registryName = util.removeNixSuffix;
mkRegistry =
path:

View File

@@ -20,6 +20,8 @@ in
{
inherit collectNixFiles;
removeNixSuffix = fileName: lib.removeSuffix ".nix" fileName;
bridgeName = id: "br-vlan${toString id}";
deriveMac =

View File

@@ -10,3 +10,14 @@ Pass `util` to Nix functions that need the helper.
`util.collectNixFiles` centralizes recursive discovery of Nix files.
Repository Nix code uses one implementation.
## Remove Nix file suffixes with the utility
### Rule
Use `util.removeNixSuffix` to remove a `.nix` suffix from a file name.
Do not call `lib.removeSuffix ".nix"` outside the utility definition.
### Rationale
The utility centralizes Nix file-name normalization.