mirror of
https://gitlab.com/upRootNutrition/dotfiles.git
synced 2025-08-10 05:44:38 -05:00
refactor: complete overhaul
This commit is contained in:
parent
0541b3d61f
commit
d99b004b5c
2 changed files with 24 additions and 54 deletions
|
@ -20,7 +20,19 @@
|
||||||
})
|
})
|
||||||
(builtins.genList (i: i) numOptions)
|
(builtins.genList (i: i) numOptions)
|
||||||
);
|
);
|
||||||
in let
|
|
||||||
|
mkOptionsFromDir = path:
|
||||||
|
builtins.listToAttrs (map
|
||||||
|
(name: {
|
||||||
|
name = builtins.substring 0 (builtins.stringLength name - 4) name;
|
||||||
|
value = stringType;
|
||||||
|
})
|
||||||
|
(
|
||||||
|
builtins.filter
|
||||||
|
(name: builtins.match ".*\\.nix$" name != null)
|
||||||
|
(builtins.attrNames (builtins.readDir path))
|
||||||
|
));
|
||||||
|
|
||||||
userSubmodule = lib.types.submodule {
|
userSubmodule = lib.types.submodule {
|
||||||
options = {
|
options = {
|
||||||
name = stringType;
|
name = stringType;
|
||||||
|
@ -32,6 +44,7 @@ in let
|
||||||
paths = genOptions stringType "path";
|
paths = genOptions stringType "path";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
instanceSubmodule = lib.types.submodule {
|
instanceSubmodule = lib.types.submodule {
|
||||||
options = {
|
options = {
|
||||||
subdomain = stringType;
|
subdomain = stringType;
|
||||||
|
@ -50,6 +63,7 @@ in let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
deviceSubmodule = lib.types.submodule {
|
deviceSubmodule = lib.types.submodule {
|
||||||
options = let
|
options = let
|
||||||
mountConfig = {
|
mountConfig = {
|
||||||
|
@ -74,33 +88,7 @@ in {
|
||||||
services = lib.mkOption {
|
services = lib.mkOption {
|
||||||
type = lib.types.submodule {
|
type = lib.types.submodule {
|
||||||
options =
|
options =
|
||||||
builtins.listToAttrs (map (name: {
|
mkOptionsFromDir ./instances/config
|
||||||
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 {
|
instances = lib.mkOption {
|
||||||
type = lib.types.attrsOf instanceSubmodule;
|
type = lib.types.attrsOf instanceSubmodule;
|
||||||
|
@ -110,21 +98,12 @@ in {
|
||||||
};
|
};
|
||||||
machines = lib.mkOption {
|
machines = lib.mkOption {
|
||||||
type = lib.types.submodule {
|
type = lib.types.submodule {
|
||||||
options =
|
options = let
|
||||||
builtins.listToAttrs (map (name: {
|
devicesPath = ./devices/config;
|
||||||
inherit name;
|
printerPath = devicesPath + /printers;
|
||||||
value = stringType;
|
in
|
||||||
})
|
mkOptionsFromDir devicesPath
|
||||||
[
|
// mkOptionsFromDir printerPath
|
||||||
"desktop"
|
|
||||||
"laptop"
|
|
||||||
"nas"
|
|
||||||
"phone"
|
|
||||||
"printer0"
|
|
||||||
"printer1"
|
|
||||||
"server"
|
|
||||||
"tablet"
|
|
||||||
])
|
|
||||||
// {
|
// {
|
||||||
devices = lib.mkOption {
|
devices = lib.mkOption {
|
||||||
type = lib.types.attrsOf deviceSubmodule;
|
type = lib.types.attrsOf deviceSubmodule;
|
||||||
|
@ -135,16 +114,7 @@ in {
|
||||||
people = lib.mkOption {
|
people = lib.mkOption {
|
||||||
type = lib.types.submodule {
|
type = lib.types.submodule {
|
||||||
options =
|
options =
|
||||||
builtins.listToAttrs (
|
mkOptionsFromDir ./users/config
|
||||||
map (name: {
|
|
||||||
inherit name;
|
|
||||||
value = stringType;
|
|
||||||
})
|
|
||||||
[
|
|
||||||
"user0"
|
|
||||||
"user1"
|
|
||||||
]
|
|
||||||
)
|
|
||||||
// {
|
// {
|
||||||
users = lib.mkOption {
|
users = lib.mkOption {
|
||||||
type = lib.types.attrsOf userSubmodule;
|
type = lib.types.attrsOf userSubmodule;
|
||||||
|
|
|
@ -14,7 +14,7 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
instances = builtins.listToAttrs (map (name: {
|
instances = builtins.listToAttrs (map (name: {
|
||||||
name = builtins.substring 0 (builtins.stringLength name - 4) name; # Remove the last 4 characters (".nix")
|
name = builtins.substring 0 (builtins.stringLength name - 4) name;
|
||||||
value = import (configPath + "/${name}") {inherit instancesFunctions;};
|
value = import (configPath + "/${name}") {inherit instancesFunctions;};
|
||||||
})
|
})
|
||||||
(builtins.filter (name:
|
(builtins.filter (name:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue