refactor(dotfiles): centralize Nix file names
This commit was merged in pull request #107.
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
inputs,
|
inputs,
|
||||||
lib,
|
|
||||||
root,
|
root,
|
||||||
specialArgs,
|
specialArgs,
|
||||||
repositoryModules,
|
repositoryModules,
|
||||||
@@ -276,7 +275,7 @@ let
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
names = map (path: lib.removeSuffix ".nix" (builtins.baseNameOf path)) files;
|
names = map util.removeNixSuffix files;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = files ++ map mkGuest names;
|
imports = files ++ map mkGuest names;
|
||||||
|
|||||||
@@ -6,13 +6,11 @@
|
|||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
definitions = lib.listToAttrs (
|
definitions = lib.listToAttrs (
|
||||||
map (path: lib.nameValuePair (registryName (builtins.baseNameOf path)) (mkRegistry path)) (
|
map (path: lib.nameValuePair (util.removeNixSuffix path) (mkRegistry path)) (
|
||||||
util.collectNixFiles root
|
util.collectNixFiles root
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
registryName = fileName: lib.removeSuffix ".nix" fileName;
|
|
||||||
|
|
||||||
mkRegistry =
|
mkRegistry =
|
||||||
path:
|
path:
|
||||||
let
|
let
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ in
|
|||||||
{
|
{
|
||||||
inherit collectNixFiles;
|
inherit collectNixFiles;
|
||||||
|
|
||||||
|
removeNixSuffix = path: lib.removeSuffix ".nix" (builtins.baseNameOf path);
|
||||||
|
|
||||||
bridgeName = id: "br-vlan${toString id}";
|
bridgeName = id: "br-vlan${toString id}";
|
||||||
|
|
||||||
deriveMac =
|
deriveMac =
|
||||||
|
|||||||
@@ -10,3 +10,14 @@ Pass `util` to Nix functions that need the helper.
|
|||||||
|
|
||||||
`util.collectNixFiles` centralizes recursive discovery of Nix files.
|
`util.collectNixFiles` centralizes recursive discovery of Nix files.
|
||||||
Repository Nix code uses one implementation.
|
Repository Nix code uses one implementation.
|
||||||
|
|
||||||
|
## Remove Nix file suffixes with the utility
|
||||||
|
|
||||||
|
### Rule
|
||||||
|
|
||||||
|
Use `util.removeNixSuffix` to remove a `.nix` suffix from a path.
|
||||||
|
Do not call `builtins.baseNameOf` or `lib.removeSuffix ".nix"` outside the utility definition.
|
||||||
|
|
||||||
|
### Rationale
|
||||||
|
|
||||||
|
The utility centralizes Nix file-name normalization.
|
||||||
|
|||||||
Reference in New Issue
Block a user