refactor: improved readability

This commit is contained in:
Nick 2024-11-07 19:39:55 -06:00
parent 14b62b909a
commit 26eee6ca61

View file

@ -21,24 +21,6 @@
(builtins.genList (i: i) numOptions)
);
in let
peopleSubmodule = lib.types.submodule {
options =
builtins.listToAttrs (
map (name: {
inherit name;
value = stringType;
})
[
"user0"
"user1"
]
)
// {
users = lib.mkOption {
type = lib.types.attrsOf userSubmodule;
};
};
};
userSubmodule = lib.types.submodule {
options = {
name = stringType;
@ -49,41 +31,6 @@ in let
paths = genOptions stringType "path";
};
};
serviceSubmodule = lib.types.submodule {
options =
builtins.listToAttrs (map (name: {
inherit name;
value = stringType;
})
[
"acme"
"caddy"
"castopod"
"forgejo"
"jellyfin"
"mastodon"
"matrix"
"minecraft"
"nextcloud"
"nginx"
"ollama"
"owncast"
"peertube"
"postgresql"
"samba"
"syncthing"
"synology"
"vaultwarden"
"web"
"wiki"
"writefreely"
])
// {
instances = lib.mkOption {
type = lib.types.attrsOf instanceSubmodule;
};
};
};
instanceSubmodule = lib.types.submodule {
options = {
subdomain = stringType;
@ -102,58 +49,107 @@ in let
};
};
};
machineSubmodule = lib.types.submodule {
options =
builtins.listToAttrs (map (name: {
inherit name;
value = stringType;
})
[
"desktop"
"laptop"
"nas"
"phone"
"printer0"
"printer1"
"server"
"tablet"
])
// {
devices = lib.mkOption {
type = lib.types.attrsOf deviceSubmodule;
};
deviceSubmodule = lib.types.submodule {
options = let
mountConfig = {
mount = stringType;
device = stringType;
options = listType;
};
in
{
boot = mountConfig;
ip = genOptions stringType "address";
label = stringType;
name = stringType;
sync = stringType;
}
// genOptions mountConfig "folder"
// genOptions mountConfig "samba"
// genOptions mountConfig "storage";
};
deviceSubmodule = let
mountConfig = {
mount = stringType;
device = stringType;
options = listType;
};
in
lib.types.submodule {
options =
{
boot = mountConfig;
ip = genOptions stringType "address";
label = stringType;
name = stringType;
sync = stringType;
}
// genOptions mountConfig "folder"
// genOptions mountConfig "samba"
// genOptions mountConfig "storage";
};
in {
options = {
services = lib.mkOption {
type = serviceSubmodule;
type = lib.types.submodule {
options =
builtins.listToAttrs (map (name: {
inherit name;
value = stringType;
})
[
"acme"
"caddy"
"castopod"
"forgejo"
"jellyfin"
"mastodon"
"matrix"
"minecraft"
"nextcloud"
"nginx"
"ollama"
"owncast"
"peertube"
"postgresql"
"samba"
"syncthing"
"synology"
"vaultwarden"
"web"
"wiki"
"writefreely"
])
// {
instances = lib.mkOption {
type = lib.types.attrsOf instanceSubmodule;
};
};
};
};
machines = lib.mkOption {
type = machineSubmodule;
type = lib.types.submodule {
options =
builtins.listToAttrs (map (name: {
inherit name;
value = stringType;
})
[
"desktop"
"laptop"
"nas"
"phone"
"printer0"
"printer1"
"server"
"tablet"
])
// {
devices = lib.mkOption {
type = lib.types.attrsOf deviceSubmodule;
};
};
};
};
people = lib.mkOption {
type = peopleSubmodule;
type = lib.types.submodule {
options =
builtins.listToAttrs (
map (name: {
inherit name;
value = stringType;
})
[
"user0"
"user1"
]
)
// {
users = lib.mkOption {
type = lib.types.attrsOf userSubmodule;
};
};
};
};
};