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,7 +31,47 @@ in let
paths = genOptions stringType "path";
};
};
serviceSubmodule = lib.types.submodule {
instanceSubmodule = lib.types.submodule {
options = {
subdomain = stringType;
label = stringType;
name = stringType;
domains = genOptions stringType "url";
dns = genOptions stringType "provider";
localhost = genOptions stringType "address";
email = genOptions stringType "address";
sops = genOptions stringType "path";
paths = genOptions stringType "path";
ports = genOptions intType "port";
ssl = {
cert = stringType;
key = stringType;
};
};
};
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";
};
in {
options = {
services = lib.mkOption {
type = lib.types.submodule {
options =
builtins.listToAttrs (map (name: {
inherit name;
@ -84,25 +106,9 @@ in let
};
};
};
instanceSubmodule = lib.types.submodule {
options = {
subdomain = stringType;
label = stringType;
name = stringType;
domains = genOptions stringType "url";
dns = genOptions stringType "provider";
localhost = genOptions stringType "address";
email = genOptions stringType "address";
sops = genOptions stringType "path";
paths = genOptions stringType "path";
ports = genOptions intType "port";
ssl = {
cert = stringType;
key = stringType;
};
};
};
machineSubmodule = lib.types.submodule {
machines = lib.mkOption {
type = lib.types.submodule {
options =
builtins.listToAttrs (map (name: {
inherit name;
@ -124,36 +130,26 @@ in let
};
};
};
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;
};
machines = lib.mkOption {
type = machineSubmodule;
};
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;
};
};
};
};
};