refactor(dotfiles): share Nix file discovery

This commit was merged in pull request #101.
This commit is contained in:
2026-09-26 23:49:03 -04:00
parent 11d11c7c02
commit 3b2d16743e
3 changed files with 8 additions and 17 deletions

View File

@@ -17,7 +17,7 @@ let
util = import ./util.nix { inherit lib; };
registry = import ./registry.nix {
inherit lib;
inherit lib util;
hosts = self.nixosConfigurations;
root = root + "/registry";
};

View File

@@ -276,10 +276,7 @@ let
};
};
names = map (file: lib.removeSuffix ".nix" file) (lib.attrNames guestFiles);
guestFiles = lib.filterAttrs (file: type: type == "regular" && lib.hasSuffix ".nix" file) (
builtins.readDir root
);
names = map (path: lib.removeSuffix ".nix" (builtins.baseNameOf path)) files;
in
{
imports = files ++ map mkGuest names;

View File

@@ -2,19 +2,13 @@
hosts,
lib,
root,
util,
}:
let
definitions =
lib.mapAttrs'
(
name: _type:
let
path = root + "/${name}";
in
lib.nameValuePair (registryName name) (mkRegistry path)
definitions = lib.listToAttrs (
map (path: lib.nameValuePair (registryName (builtins.baseNameOf path)) (mkRegistry path)) (
util.collectNixFiles root
)
(
lib.filterAttrs (name: type: type == "regular" && lib.hasSuffix ".nix" name) (builtins.readDir root)
);
registryName = fileName: lib.removeSuffix ".nix" fileName;