2022-12-04 13:45:43 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib; let
|
|
|
|
cfg = config.mailserver;
|
2022-11-17 12:06:16 +00:00
|
|
|
in {
|
|
|
|
options.mailserver = {
|
|
|
|
enable = mkEnableOption "mailserver";
|
|
|
|
|
2022-12-04 13:45:43 +00:00
|
|
|
fqdn = mkOption {type = types.str;};
|
2022-11-17 12:06:16 +00:00
|
|
|
|
2022-12-04 13:45:43 +00:00
|
|
|
domains = mkOption {type = types.listOf types.str;};
|
2022-11-17 12:06:16 +00:00
|
|
|
|
|
|
|
ssl_config = mkOption {
|
2022-12-04 13:45:43 +00:00
|
|
|
type = types.submodule {
|
2022-11-17 12:06:16 +00:00
|
|
|
options = {
|
|
|
|
useACME = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
};
|
|
|
|
cert = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "/var/lib/acme/${cfg.fqdn}/fullchain.pem";
|
|
|
|
};
|
|
|
|
key = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "/var/lib/acme/${cfg.fqdn}/key.pem";
|
|
|
|
};
|
|
|
|
};
|
2022-12-04 13:45:43 +00:00
|
|
|
};
|
|
|
|
default = {};
|
2022-11-17 12:06:16 +00:00
|
|
|
};
|
2022-12-02 16:07:06 +00:00
|
|
|
|
2022-11-17 12:06:16 +00:00
|
|
|
debug_mode = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
};
|
|
|
|
|
2022-12-02 16:07:06 +00:00
|
|
|
enable_roundcube = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
roundcube_url = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "${cfg.fqdn}";
|
|
|
|
};
|
|
|
|
|
2022-11-17 12:06:16 +00:00
|
|
|
accounts = mkOption {
|
|
|
|
# where name = email for login
|
2022-12-04 16:10:00 +00:00
|
|
|
type = types.attrsOf (types.submodule ({name, ...}: {
|
2022-11-17 12:06:16 +00:00
|
|
|
options = {
|
|
|
|
name = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = name;
|
|
|
|
};
|
2022-12-04 13:45:43 +00:00
|
|
|
passwordFile = mkOption {type = types.str;};
|
|
|
|
aliases = mkOption {type = types.listOf types.str;};
|
|
|
|
sieveScript = mkOption {type = types.nullOr types.lines;};
|
2022-11-17 12:06:16 +00:00
|
|
|
};
|
|
|
|
}));
|
|
|
|
};
|
|
|
|
|
2022-12-04 13:45:43 +00:00
|
|
|
extra_aliases_file = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
|
2022-11-17 12:06:16 +00:00
|
|
|
sieve_directory = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "/var/sieve";
|
|
|
|
};
|
2022-12-04 13:45:43 +00:00
|
|
|
|
2022-11-17 12:06:16 +00:00
|
|
|
dkim_directory = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "/var/dkim";
|
|
|
|
};
|
|
|
|
|
|
|
|
policyd_config = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
};
|
|
|
|
|
2022-12-02 16:07:06 +00:00
|
|
|
extra_roundcube_config = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
};
|
|
|
|
|
2022-11-17 12:06:16 +00:00
|
|
|
vmail_config = mkOption {
|
2022-12-04 13:45:43 +00:00
|
|
|
type = types.submodule {
|
2022-11-17 12:06:16 +00:00
|
|
|
options = {
|
2022-12-04 13:45:43 +00:00
|
|
|
user = mkOption {
|
2022-11-17 12:06:16 +00:00
|
|
|
type = types.str;
|
|
|
|
default = "vmail";
|
|
|
|
};
|
2022-12-04 13:45:43 +00:00
|
|
|
group = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "${cfg.vmail_config.user}";
|
|
|
|
};
|
|
|
|
user_id = mkOption {
|
2022-11-17 12:06:16 +00:00
|
|
|
type = types.number;
|
|
|
|
default = 5000;
|
|
|
|
};
|
2022-12-04 13:45:43 +00:00
|
|
|
group_id = mkOption {
|
|
|
|
type = types.number;
|
|
|
|
default = cfg.vmail_config.user_id;
|
|
|
|
};
|
2022-11-17 12:06:16 +00:00
|
|
|
directory = mkOption {
|
|
|
|
type = types.str;
|
2022-12-04 13:45:43 +00:00
|
|
|
default = "/home/${cfg.vmail_config.user}";
|
2022-11-17 12:06:16 +00:00
|
|
|
};
|
|
|
|
};
|
2022-12-04 13:45:43 +00:00
|
|
|
};
|
|
|
|
default = {};
|
2022-11-17 12:06:16 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|