nixfiles/hosts/hetzner-arm/containers/mail/modules/mailserver/default.nix

145 lines
3.3 KiB
Nix
Raw Normal View History

{
config,
lib,
...
2023-09-18 03:56:58 +01:00
}: let
inherit (lib) types;
inherit (lib.options) mkEnableOption mkOption;
2023-09-18 03:56:58 +01:00
cfg = config.services.mailserver;
2022-11-17 12:06:16 +00:00
in {
options.services.mailserver = {
2022-11-17 12:06:16 +00:00
enable = mkEnableOption "mailserver";
2023-09-18 03:56:58 +01:00
fqdn = mkOption {
type = types.str;
description = "domain used for mx records";
};
2022-11-17 12:06:16 +00:00
2023-09-18 03:56:58 +01:00
domains = mkOption {
type = types.listOf types.str;
description = "all domains for receiving mail on";
2022-11-17 12:06:16 +00:00
};
2023-09-18 03:56:58 +01:00
debugMode = mkOption {
2022-11-17 12:06:16 +00:00
type = types.bool;
default = false;
2023-09-18 03:56:58 +01:00
description = "enable debug logging on everything";
2022-11-17 12:06:16 +00:00
};
2023-09-18 03:56:58 +01:00
sslConfig = {
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";
};
};
2023-09-18 03:56:58 +01:00
spf = {
enable = mkOption {
type = types.bool;
default = true;
};
policydConfig = mkOption {
type = types.str;
default = "";
};
2023-08-09 15:11:04 +01:00
};
2023-09-18 03:56:58 +01:00
rspamd = {
enable = mkOption {
type = types.bool;
default = true;
};
extraConfig = mkOption {
type = types.lines;
default = "";
};
redisPort = mkOption {
type = types.number;
default = 6380;
};
2023-08-09 15:11:04 +01:00
};
2022-11-17 12:06:16 +00:00
accounts = mkOption {
2023-09-18 03:56:58 +01:00
# where attrName = email for login
default = {};
type = types.attrsOf (types.submodule {
2022-11-17 12:06:16 +00:00
options = {
2023-09-18 03:56:58 +01:00
passwordHashFile = mkOption {
2022-11-17 12:06:16 +00:00
type = types.str;
2023-09-18 03:56:58 +01:00
description = ''
a file containing the hashed password for user, loaded at runtime
'';
};
aliases = mkOption {
type = types.listOf types.str;
default = [];
description = "a list of aliases for receiving/sending mail";
};
sieveScript = mkOption {
type = types.nullOr types.lines;
default = null;
description = "a default sieve script for filtering mail";
2022-11-17 12:06:16 +00:00
};
};
2023-09-18 03:56:58 +01:00
});
2022-11-17 12:06:16 +00:00
};
2023-09-18 03:56:58 +01:00
extraAliasesFile = mkOption {
type = types.nullOr types.str;
default = null;
2023-09-18 03:56:58 +01:00
description = "file containing postfix aliases for receiving, loaded at runtime";
};
2023-09-18 03:56:58 +01:00
sieveDirectory = mkOption {
2022-11-17 12:06:16 +00:00
type = types.str;
default = "/var/sieve";
2023-09-18 03:56:58 +01:00
description = "path used for storing sieve scripts";
2022-11-17 12:06:16 +00:00
};
2023-09-18 03:56:58 +01:00
dkim = {
enable = mkOption {
type = types.bool;
default = true;
};
directory = mkOption {
type = types.str;
default = "/var/dkim";
description = "path used for storing dkim signing keys, make sure to keep this backed up";
};
};
2023-09-18 03:56:58 +01:00
vmail = {
user = mkOption {
type = types.str;
default = "vmail";
};
group = mkOption {
type = types.str;
default = "${cfg.vmail.user}";
};
userID = mkOption {
type = types.number;
default = 5000;
};
groupID = mkOption {
type = types.number;
default = cfg.vmail.userID;
};
directory = mkOption {
type = types.str;
default = "/home/${cfg.vmail.user}";
};
2022-11-17 12:06:16 +00:00
};
};
}