2022-11-25 15:24:05 +01:00
|
|
|
{ config, pkgs, ... }:
|
2022-12-17 21:33:45 +01:00
|
|
|
let
|
2023-01-06 16:57:26 +01:00
|
|
|
hostname = "mail.${config.fsr.domain}";
|
|
|
|
domain = config.fsr.domain;
|
2022-12-17 21:33:45 +01:00
|
|
|
in
|
|
|
|
{
|
2023-01-06 16:57:26 +01:00
|
|
|
sops.secrets."rspamd-password".owner = config.users.user.rspamd.name;
|
|
|
|
|
|
|
|
networking.firewall.allowedTCPPorts = [ 25 465 993 ];
|
|
|
|
|
2022-12-17 21:33:45 +01:00
|
|
|
services = {
|
|
|
|
postfix = {
|
|
|
|
enable = true;
|
|
|
|
hostname = "${hostname}";
|
|
|
|
domain = "${domain}";
|
|
|
|
relayHost = "";
|
|
|
|
origin = "${domain}";
|
|
|
|
destination = [ "${hostname}" "${domain}" "localhost" ];
|
2023-01-06 16:57:26 +01:00
|
|
|
sslCert = "/var/lib/acme/${hostname}/fullchain.pem";
|
|
|
|
sslKey = "/var/lib/acme/${hostname}/key.pem";
|
2022-12-17 21:33:45 +01:00
|
|
|
config = {
|
|
|
|
smtpd_recipient_restrictions = [
|
|
|
|
"reject_unauth_destination"
|
|
|
|
"permit_sasl_authenticated"
|
|
|
|
"permit_mynetworks"
|
|
|
|
];
|
|
|
|
smtpd_sasl_auth_enable = true;
|
|
|
|
smtpd_sasl_path = "/var/lib/postfix/auth";
|
2023-01-06 16:57:26 +01:00
|
|
|
virtual_mailbox_base = "/var/spool/mail";
|
2022-12-17 21:33:45 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
dovecot2 = {
|
|
|
|
enable = true;
|
|
|
|
enableImap = true;
|
|
|
|
enableQuota = false;
|
2023-01-06 16:57:26 +01:00
|
|
|
sslServerCert = "/var/lib/acme/${hostname}/fullchain.pem";
|
|
|
|
sslServerKey = "/var/lib/acme/${hostname}/key.pem";
|
2022-12-17 21:33:45 +01:00
|
|
|
mailboxes = {
|
|
|
|
Spam = {
|
|
|
|
auto = "create";
|
|
|
|
specialUse = "Junk";
|
|
|
|
};
|
|
|
|
Sent = {
|
|
|
|
auto = "create";
|
|
|
|
specialUse = "Sent";
|
|
|
|
};
|
|
|
|
Drafts = {
|
|
|
|
auto = "create";
|
|
|
|
specialUse = "Drafts";
|
|
|
|
};
|
|
|
|
Trash = {
|
|
|
|
auto = "create";
|
|
|
|
specialUse = "Trash";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
extraConfig = ''
|
2023-01-06 16:57:26 +01:00
|
|
|
mail_location = maildir:/var/mail/%u
|
2022-12-17 21:33:45 +01:00
|
|
|
auth_mechanisms = plain login
|
|
|
|
disable_plaintext_auth = no
|
|
|
|
userdb {
|
2023-01-06 16:57:26 +01:00
|
|
|
driver = passwd
|
|
|
|
args = blocking=no
|
2022-12-17 21:33:45 +01:00
|
|
|
}
|
|
|
|
service auth {
|
2023-01-06 16:57:26 +01:00
|
|
|
unix_listener /var/lib/postfix/auth {
|
2022-12-17 21:33:45 +01:00
|
|
|
group = postfix
|
|
|
|
mode = 0660
|
|
|
|
user = postfix
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
rspamd = {
|
|
|
|
enable = true;
|
2023-01-06 16:57:26 +01:00
|
|
|
postfix.enable = true;
|
|
|
|
locals = {
|
|
|
|
"worker-controller.inc".source = config.sops.secrets."rspamd-password".path;
|
2022-12-17 21:33:45 +01:00
|
|
|
};
|
|
|
|
};
|
2023-01-06 16:57:26 +01:00
|
|
|
nginx = {
|
2022-12-17 21:33:45 +01:00
|
|
|
enable = true;
|
2023-01-06 16:57:26 +01:00
|
|
|
virtualHosts."${hostname}" = {
|
|
|
|
forceSSL = true;
|
|
|
|
enableACME = true;
|
|
|
|
};
|
2022-12-17 21:33:45 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|