dotfiles/config/default.nix

181 lines
4.2 KiB
Nix
Raw Normal View History

2025-01-18 03:50:54 -06:00
{ lib, ... }:
let
2024-10-06 15:25:05 -05:00
stringType = lib.mkOption {
type = lib.types.str;
};
intType = lib.mkOption {
type = lib.types.int;
};
listType = lib.mkOption {
type = lib.types.listOf lib.types.str;
};
2024-12-19 19:56:45 -06:00
attrList = lib.mkOption {
type = lib.types.attrsOf lib.types.str;
};
2025-01-14 16:17:42 -06:00
boolType = lib.mkOption {
type = lib.types.bool;
};
2024-10-06 15:25:05 -05:00
numOptions = 20;
2025-01-18 03:50:54 -06:00
genOptions =
config: prefix:
2024-10-06 15:25:05 -05:00
builtins.listToAttrs (
2025-01-18 03:50:54 -06:00
map (i: {
2024-10-06 15:25:05 -05:00
name = "${prefix}${toString i}";
value = config;
2025-01-18 03:50:54 -06:00
}) (builtins.genList (i: i) numOptions)
2024-10-06 15:25:05 -05:00
);
2024-11-10 01:49:34 -06:00
2025-01-18 03:50:54 -06:00
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)
)
)
);
2024-11-10 01:49:34 -06:00
2024-10-06 15:25:05 -05:00
userSubmodule = lib.types.submodule {
options = {
name = stringType;
2024-11-10 01:29:37 -06:00
label = stringType;
2024-10-06 15:25:05 -05:00
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
};
};
2024-11-10 01:49:34 -06:00
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-10 01:49:34 -06:00
2024-11-07 19:39:55 -06:00
deviceSubmodule = lib.types.submodule {
2025-01-18 03:50:54 -06:00
options =
let
mountConfig = {
mount = stringType;
device = stringType;
options = listType;
};
in
2024-11-07 19:39:55 -06:00
{
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
};
2024-12-19 19:56:45 -06:00
themesSubmodule = lib.types.submodule {
options = {
2025-01-14 16:17:42 -06:00
currentTheme = stringType;
2025-01-18 03:50:54 -06:00
font = {
name = stringType;
size = {
2025-01-18 17:05:54 -06:00
applications = intType;
desktop = intType;
popups = intType;
terminal = intType;
2025-01-18 03:50:54 -06:00
};
2025-01-18 17:05:54 -06:00
};
cursor = {
name = stringType;
size = intType;
2025-01-18 03:50:54 -06:00
};
palettes = lib.mkOption {
type = lib.types.attrsOf (
lib.types.submodule {
options = {
colours = attrList;
font = stringType;
};
}
);
2025-01-14 16:17:42 -06:00
};
2025-01-18 17:05:54 -06:00
2024-12-19 19:56:45 -06:00
};
};
2025-01-18 03:50:54 -06:00
in
{
2024-10-06 15:25:05 -05:00
options = {
2024-11-04 20:49:43 -06:00
services = lib.mkOption {
2024-11-07 19:39:55 -06:00
type = lib.types.submodule {
2025-01-18 03:50:54 -06:00
options = mkOptionsFromDir ./instances/config // {
instances = lib.mkOption {
type = lib.types.attrsOf instanceSubmodule;
2024-11-07 19:39:55 -06:00
};
2025-01-18 03:50:54 -06:00
};
2024-11-07 19:39:55 -06:00
};
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 {
2025-01-18 03:50:54 -06:00
options =
let
devicesPath = ./devices/config;
printerPath = devicesPath + /printers;
in
2024-11-10 01:49:34 -06:00
mkOptionsFromDir devicesPath
// mkOptionsFromDir printerPath
2024-11-07 19:39:55 -06:00
// {
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 {
2025-01-18 03:50:54 -06:00
options = mkOptionsFromDir ./users/config // {
users = lib.mkOption {
type = lib.types.attrsOf userSubmodule;
2024-11-07 19:39:55 -06:00
};
2025-01-18 03:50:54 -06:00
};
2024-11-07 19:39:55 -06:00
};
2024-10-06 15:25:05 -05:00
};
2024-12-19 19:56:45 -06:00
aesthetics = lib.mkOption {
type = lib.types.submodule {
2025-01-18 03:50:54 -06:00
options = mkOptionsFromDir ./themes // {
themes = lib.mkOption {
type = themesSubmodule;
2024-12-19 19:56:45 -06:00
};
2025-01-18 03:50:54 -06:00
};
2024-12-19 19:56:45 -06:00
};
};
2024-10-06 15:25:05 -05:00
};
config = {
2024-11-10 01:29:37 -06:00
people = import ./users;
services = import ./instances;
machines = import ./devices;
2024-12-19 19:56:45 -06:00
aesthetics = import ./themes;
2024-10-06 15:25:05 -05:00
};
}