refactor(host): simplify host assembly
This commit is contained in:
@@ -51,7 +51,6 @@ let
|
||||
inherit
|
||||
inputs
|
||||
lib
|
||||
self
|
||||
specialArgs
|
||||
guestFiles
|
||||
registryAssembly
|
||||
|
||||
@@ -1,46 +1,51 @@
|
||||
{
|
||||
inputs,
|
||||
lib,
|
||||
self,
|
||||
specialArgs,
|
||||
repositoryModules,
|
||||
|
||||
# TODO refactor guests
|
||||
guestFiles,
|
||||
# TODO refactor registry
|
||||
registryAssembly,
|
||||
}:
|
||||
let
|
||||
mkHost =
|
||||
{
|
||||
hostName,
|
||||
system ? "x86_64-linux",
|
||||
root,
|
||||
name,
|
||||
}:
|
||||
inputs.nixpkgs.lib.nixosSystem {
|
||||
inherit system specialArgs;
|
||||
lib.nixosSystem {
|
||||
inherit specialArgs;
|
||||
modules =
|
||||
[
|
||||
repositoryModules
|
||||
]
|
||||
++ guestFiles
|
||||
guestFiles
|
||||
++ [
|
||||
inputs.chaotic.nixosModules.default
|
||||
inputs.disko.nixosModules.disko
|
||||
inputs.sops-nix.nixosModules.sops
|
||||
inputs.stylix.nixosModules.stylix
|
||||
registryAssembly.module
|
||||
(self + "/hosts/${hostName}")
|
||||
|
||||
repositoryModules
|
||||
|
||||
# TODO: refactor
|
||||
registryAssembly.module (root + "/${name}")
|
||||
|
||||
{
|
||||
networking.hostName = hostName;
|
||||
networking.hostName = name;
|
||||
modules.host.enable = true;
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
mkHosts =
|
||||
hostsDir:
|
||||
let
|
||||
hostNames = lib.attrNames (lib.filterAttrs (_name: type: type == "directory") (builtins.readDir hostsDir));
|
||||
in
|
||||
lib.genAttrs hostNames (hostName: mkHost { inherit hostName; });
|
||||
in
|
||||
{
|
||||
inherit mkHosts;
|
||||
mkHosts =
|
||||
{ root }:
|
||||
let
|
||||
directories = lib.filterAttrs (_name: type: type == "directory") (builtins.readDir root);
|
||||
names = lib.attrNames directories;
|
||||
in
|
||||
lib.genAttrs names (
|
||||
name:
|
||||
mkHost { inherit root name; }
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user