dotfiles/config/default.nix

162 lines
3.7 KiB
Nix
Raw Normal View History

2024-10-06 15:25:05 -05:00
{lib, ...}: let
stringType = lib.mkOption {
type = lib.types.str;
};
intType = lib.mkOption {
type = lib.types.int;
};
listType = lib.mkOption {
type = lib.types.listOf lib.types.str;
};
numOptions = 20;
genOptions = config: prefix:
builtins.listToAttrs (
map
(i: {
name = "${prefix}${toString i}";
value = config;
})
(builtins.genList (i: i) numOptions)
);
in let
userSubmodule = lib.types.submodule {
options = {
name = stringType;
sshKeys = listType;
group = stringType;
2024-10-23 15:16:43 -05:00
aliases = genOptions stringType "name";
2024-10-06 15:25:05 -05:00
email = genOptions stringType "address";
2024-10-19 18:22:29 -05:00
paths = genOptions stringType "path";
2024-10-06 15:25:05 -05:00
};
};
instanceSubmodule = lib.types.submodule {
options = {
subdomain = stringType;
label = stringType;
name = stringType;
2024-10-19 18:22:29 -05:00
domains = genOptions stringType "url";
dns = genOptions stringType "provider";
localhost = genOptions stringType "address";
email = genOptions stringType "address";
2024-10-06 15:25:05 -05:00
sops = genOptions stringType "path";
paths = genOptions stringType "path";
ports = genOptions intType "port";
ssl = {
cert = stringType;
key = stringType;
};
};
};
2024-11-07 19:39:55 -06:00
deviceSubmodule = lib.types.submodule {
options = let
mountConfig = {
mount = stringType;
device = stringType;
options = listType;
2024-10-06 15:25:05 -05:00
};
2024-11-07 19:39:55 -06:00
in
{
boot = mountConfig;
ip = genOptions stringType "address";
label = stringType;
name = stringType;
sync = stringType;
}
// genOptions mountConfig "folder"
// genOptions mountConfig "samba"
// genOptions mountConfig "storage";
2024-10-06 15:25:05 -05:00
};
in {
options = {
2024-11-04 20:49:43 -06:00
services = lib.mkOption {
2024-11-07 19:39:55 -06:00
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;
};
};
};
2024-10-06 15:25:05 -05:00
};
2024-11-04 20:49:43 -06:00
machines = lib.mkOption {
2024-11-07 19:39:55 -06:00
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;
};
};
};
2024-10-06 15:25:05 -05:00
};
people = lib.mkOption {
2024-11-07 19:39:55 -06:00
type = lib.types.submodule {
options =
builtins.listToAttrs (
map (name: {
inherit name;
value = stringType;
})
[
"user0"
"user1"
]
)
// {
users = lib.mkOption {
type = lib.types.attrsOf userSubmodule;
};
};
};
2024-10-06 15:25:05 -05:00
};
};
config = {
2024-11-04 20:49:43 -06:00
people = import ./users.nix;
services = import ./instances.nix;
machines = import ./devices.nix;
2024-10-06 15:25:05 -05:00
};
}