mirror of
https://gitlab.com/upRootNutrition/dotfiles.git
synced 2025-06-16 18:15:13 -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)
|
||||
);
|
||||
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 {
|
||||
options = {
|
||||
name = stringType;
|
||||
|
@ -32,6 +44,7 @@ in let
|
|||
paths = genOptions stringType "path";
|
||||
};
|
||||
};
|
||||
|
||||
instanceSubmodule = lib.types.submodule {
|
||||
options = {
|
||||
subdomain = stringType;
|
||||
|
@ -50,6 +63,7 @@ in let
|
|||
};
|
||||
};
|
||||
};
|
||||
|
||||
deviceSubmodule = lib.types.submodule {
|
||||
options = let
|
||||
mountConfig = {
|
||||
|
@ -74,33 +88,7 @@ in {
|
|||
services = lib.mkOption {
|
||||
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"
|
||||
])
|
||||
mkOptionsFromDir ./instances/config
|
||||
// {
|
||||
instances = lib.mkOption {
|
||||
type = lib.types.attrsOf instanceSubmodule;
|
||||
|
@ -110,21 +98,12 @@ in {
|
|||
};
|
||||
machines = lib.mkOption {
|
||||
type = lib.types.submodule {
|
||||
options =
|
||||
builtins.listToAttrs (map (name: {
|
||||
inherit name;
|
||||
value = stringType;
|
||||
})
|
||||
[
|
||||
"desktop"
|
||||
"laptop"
|
||||
"nas"
|
||||
"phone"
|
||||
"printer0"
|
||||
"printer1"
|
||||
"server"
|
||||
"tablet"
|
||||
])
|
||||
options = let
|
||||
devicesPath = ./devices/config;
|
||||
printerPath = devicesPath + /printers;
|
||||
in
|
||||
mkOptionsFromDir devicesPath
|
||||
// mkOptionsFromDir printerPath
|
||||
// {
|
||||
devices = lib.mkOption {
|
||||
type = lib.types.attrsOf deviceSubmodule;
|
||||
|
@ -135,16 +114,7 @@ in {
|
|||
people = lib.mkOption {
|
||||
type = lib.types.submodule {
|
||||
options =
|
||||
builtins.listToAttrs (
|
||||
map (name: {
|
||||
inherit name;
|
||||
value = stringType;
|
||||
})
|
||||
[
|
||||
"user0"
|
||||
"user1"
|
||||
]
|
||||
)
|
||||
mkOptionsFromDir ./users/config
|
||||
// {
|
||||
users = lib.mkOption {
|
||||
type = lib.types.attrsOf userSubmodule;
|
||||
|
|
|
@ -14,7 +14,7 @@ let
|
|||
};
|
||||
|
||||
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;};
|
||||
})
|
||||
(builtins.filter (name:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue