296 lines
6.0 KiB
Nix
296 lines
6.0 KiB
Nix
{ lib, ... }:
|
|
let
|
|
sourceControlScopeType = lib.types.enum [
|
|
"personal"
|
|
"work"
|
|
];
|
|
|
|
emailProviderType = lib.types.enum [
|
|
"mxrouting"
|
|
"office365"
|
|
];
|
|
|
|
emailType = lib.types.submodule (
|
|
{ ... }:
|
|
{
|
|
options = {
|
|
address = lib.mkOption {
|
|
type = lib.types.str;
|
|
};
|
|
|
|
primary = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = false;
|
|
};
|
|
|
|
type = lib.mkOption {
|
|
type = emailProviderType;
|
|
};
|
|
|
|
scope = lib.mkOption {
|
|
type = lib.types.nullOr sourceControlScopeType;
|
|
default = null;
|
|
};
|
|
};
|
|
}
|
|
);
|
|
|
|
sourceControlAccountType = lib.types.submodule (
|
|
{ ... }:
|
|
{
|
|
options.projectScope = lib.mkOption {
|
|
type = sourceControlScopeType;
|
|
default = "personal";
|
|
};
|
|
}
|
|
);
|
|
|
|
accountType = lib.types.submodule (
|
|
{ name, config, ... }:
|
|
{
|
|
options = {
|
|
name = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = name;
|
|
};
|
|
|
|
realName = lib.mkOption {
|
|
type = lib.types.str;
|
|
};
|
|
|
|
homeDirectory = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "/home/${config.name}";
|
|
};
|
|
|
|
nixosConfigurationPath = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "${config.homeDirectory}/.config/nixos";
|
|
};
|
|
|
|
emails = lib.mkOption {
|
|
type = lib.types.attrsOf emailType;
|
|
default = { };
|
|
};
|
|
|
|
baseModule = lib.mkOption {
|
|
type = lib.types.deferredModule;
|
|
default = { };
|
|
};
|
|
|
|
workstationModule = lib.mkOption {
|
|
type = lib.types.deferredModule;
|
|
default = { };
|
|
};
|
|
|
|
sourceControl = lib.mkOption {
|
|
type = sourceControlAccountType;
|
|
default = { };
|
|
};
|
|
|
|
primaryEmail = lib.mkOption {
|
|
type = lib.types.nullOr emailType;
|
|
description = "Derived primary email entry for this user.";
|
|
default =
|
|
let
|
|
emails = builtins.attrValues config.emails;
|
|
in
|
|
lib.findFirst (email: email.primary) null emails;
|
|
};
|
|
};
|
|
}
|
|
);
|
|
|
|
displayType = lib.types.submodule (
|
|
{ ... }:
|
|
{
|
|
options = {
|
|
primary = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = false;
|
|
};
|
|
|
|
x = lib.mkOption {
|
|
type = lib.types.int;
|
|
default = 0;
|
|
};
|
|
|
|
y = lib.mkOption {
|
|
type = lib.types.int;
|
|
default = 0;
|
|
};
|
|
|
|
scale = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.float;
|
|
default = null;
|
|
};
|
|
|
|
width = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.int;
|
|
default = null;
|
|
};
|
|
|
|
height = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.int;
|
|
default = null;
|
|
};
|
|
|
|
refresh = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.float;
|
|
default = null;
|
|
};
|
|
};
|
|
}
|
|
);
|
|
|
|
sourceControlMachineKeyType = lib.types.submodule (
|
|
{ ... }:
|
|
{
|
|
options = {
|
|
publicKey = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.str;
|
|
default = null;
|
|
};
|
|
|
|
privateKeyPath = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.str;
|
|
default = null;
|
|
};
|
|
};
|
|
}
|
|
);
|
|
|
|
sourceControlMachineUserType = lib.types.submodule (
|
|
{ ... }:
|
|
{
|
|
options = {
|
|
personal = lib.mkOption {
|
|
type = lib.types.nullOr sourceControlMachineKeyType;
|
|
default = null;
|
|
};
|
|
|
|
work = lib.mkOption {
|
|
type = lib.types.nullOr sourceControlMachineKeyType;
|
|
default = null;
|
|
};
|
|
};
|
|
}
|
|
);
|
|
|
|
machineUserType = lib.types.submodule (
|
|
{ ... }:
|
|
{
|
|
options = {
|
|
account = lib.mkOption {
|
|
type = accountType;
|
|
};
|
|
|
|
sourceControl = lib.mkOption {
|
|
type = sourceControlMachineUserType;
|
|
default = { };
|
|
};
|
|
|
|
syncthingId = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.str;
|
|
default = null;
|
|
};
|
|
};
|
|
}
|
|
);
|
|
|
|
machineType = lib.types.submodule (
|
|
{ name, config, ... }:
|
|
{
|
|
options = {
|
|
name = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = name;
|
|
};
|
|
|
|
module = lib.mkOption {
|
|
type = lib.types.deferredModule;
|
|
default = { };
|
|
};
|
|
|
|
buildFunction = lib.mkOption {
|
|
type = lib.types.functionTo lib.types.deferredModule;
|
|
};
|
|
|
|
stateVersion = lib.mkOption {
|
|
type = lib.types.str;
|
|
};
|
|
|
|
hmStateVersion = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = config.stateVersion;
|
|
};
|
|
|
|
displays = lib.mkOption {
|
|
type = lib.types.attrsOf displayType;
|
|
default = { };
|
|
};
|
|
|
|
users = lib.mkOption {
|
|
type = lib.types.attrsOf machineUserType;
|
|
default = { };
|
|
};
|
|
};
|
|
}
|
|
);
|
|
in
|
|
{
|
|
options.repo = {
|
|
accounts = lib.mkOption {
|
|
type = lib.types.attrsOf accountType;
|
|
default = { };
|
|
};
|
|
|
|
machines = lib.mkOption {
|
|
type = lib.types.attrsOf machineType;
|
|
default = { };
|
|
};
|
|
|
|
contact = lib.mkOption {
|
|
type = lib.types.raw;
|
|
default = { };
|
|
};
|
|
|
|
desktop = lib.mkOption {
|
|
type = lib.types.raw;
|
|
default = { };
|
|
};
|
|
|
|
services = lib.mkOption {
|
|
type = lib.types.raw;
|
|
default = { };
|
|
};
|
|
|
|
theme = lib.mkOption {
|
|
type = lib.types.raw;
|
|
default = { };
|
|
};
|
|
};
|
|
|
|
config.flake.modules.nixos.meta =
|
|
{ ... }:
|
|
{
|
|
options.meta.machine = lib.mkOption {
|
|
type = machineType;
|
|
};
|
|
};
|
|
|
|
config.flake.modules.homeManager.meta =
|
|
{ ... }:
|
|
{
|
|
options.meta = {
|
|
machine = lib.mkOption {
|
|
type = machineType;
|
|
};
|
|
|
|
user = lib.mkOption {
|
|
type = machineUserType;
|
|
};
|
|
};
|
|
};
|
|
}
|