refactor(dotfiles): share Nix file discovery #101
@@ -17,7 +17,7 @@ let
|
|||||||
util = import ./util.nix { inherit lib; };
|
util = import ./util.nix { inherit lib; };
|
||||||
|
|
||||||
registry = import ./registry.nix {
|
registry = import ./registry.nix {
|
||||||
inherit lib;
|
inherit lib util;
|
||||||
hosts = self.nixosConfigurations;
|
hosts = self.nixosConfigurations;
|
||||||
root = root + "/registry";
|
root = root + "/registry";
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -276,10 +276,7 @@ let
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
names = map (file: lib.removeSuffix ".nix" file) (lib.attrNames guestFiles);
|
names = map (path: lib.removeSuffix ".nix" (builtins.baseNameOf path)) files;
|
||||||
guestFiles = lib.filterAttrs (file: type: type == "regular" && lib.hasSuffix ".nix" file) (
|
|
||||||
builtins.readDir root
|
|
||||||
);
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = files ++ map mkGuest names;
|
imports = files ++ map mkGuest names;
|
||||||
|
|||||||
@@ -2,19 +2,13 @@
|
|||||||
hosts,
|
hosts,
|
||||||
lib,
|
lib,
|
||||||
root,
|
root,
|
||||||
|
util,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
definitions =
|
definitions = lib.listToAttrs (
|
||||||
lib.mapAttrs'
|
map (path: lib.nameValuePair (registryName (builtins.baseNameOf path)) (mkRegistry path)) (
|
||||||
(
|
util.collectNixFiles root
|
||||||
name: _type:
|
|
||||||
let
|
|
||||||
path = root + "/${name}";
|
|
||||||
in
|
|
||||||
lib.nameValuePair (registryName name) (mkRegistry path)
|
|
||||||
)
|
)
|
||||||
(
|
|
||||||
lib.filterAttrs (name: type: type == "regular" && lib.hasSuffix ".nix" name) (builtins.readDir root)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
registryName = fileName: lib.removeSuffix ".nix" fileName;
|
registryName = fileName: lib.removeSuffix ".nix" fileName;
|
||||||
|
|||||||
Reference in New Issue
Block a user