2023-10-28 22:31:09 +00:00
|
|
|
{ flake
|
|
|
|
, config
|
|
|
|
, lib
|
|
|
|
, pkgs
|
|
|
|
, ...
|
|
|
|
}:
|
|
|
|
{
|
|
|
|
networking.firewall.allowedTCPPorts = [ 25 ];
|
|
|
|
|
2023-10-29 01:39:32 +00:00
|
|
|
users.users.nginx.extraGroups = [ "mailman" ];
|
|
|
|
|
2024-05-08 17:47:47 +00:00
|
|
|
services.nginx.virtualHosts."list.${config.pub-solar-os.networking.domain}" = {
|
2023-10-29 01:39:32 +00:00
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
|
|
|
};
|
2023-10-29 01:49:09 +00:00
|
|
|
# Tweak permissions so nginx can read and serve the static assets
|
|
|
|
# (otherwise /var/lib/mailman-web is mode 0600)
|
|
|
|
# https://nixos.wiki/wiki/Mailman
|
|
|
|
systemd.services.mailman-settings.script = ''
|
|
|
|
chmod o+x /var/lib/mailman-web-static
|
|
|
|
'';
|
2023-10-29 01:39:32 +00:00
|
|
|
|
2023-10-28 22:31:09 +00:00
|
|
|
services.postfix = {
|
|
|
|
enable = true;
|
|
|
|
relayDomains = [ "hash:/var/lib/mailman/data/postfix_domains" ];
|
|
|
|
# get TLS certs for list.pub.solar from acme
|
2024-05-08 17:47:47 +00:00
|
|
|
sslCert = "/var/lib/acme/list.${config.pub-solar-os.networking.domain}/fullchain.pem";
|
|
|
|
sslKey = "/var/lib/acme/list.${config.pub-solar-os.networking.domain}/key.pem";
|
2023-10-28 22:31:09 +00:00
|
|
|
config = {
|
|
|
|
transport_maps = [ "hash:/var/lib/mailman/data/postfix_lmtp" ];
|
|
|
|
local_recipient_maps = [ "hash:/var/lib/mailman/data/postfix_lmtp" ];
|
|
|
|
};
|
|
|
|
rootAlias = "admins@pub.solar";
|
|
|
|
postmasterAlias = "admins@pub.solar";
|
2024-05-08 17:47:47 +00:00
|
|
|
hostname = "list.${config.pub-solar-os.networking.domain}";
|
2023-10-28 22:31:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
systemd.paths.watcher-acme-ssl-file = {
|
|
|
|
description = "Watches for changes in acme's TLS cert file (after renewals) to reload postfix";
|
|
|
|
documentation = [ "systemd.path(5)" ];
|
|
|
|
partOf = [ "postfix-reload.service" ];
|
|
|
|
pathConfig = {
|
2024-05-08 17:47:47 +00:00
|
|
|
PathChanged = "/var/lib/acme/list.${config.pub-solar-os.networking.domain}/fullchain.pem";
|
2023-10-28 22:31:09 +00:00
|
|
|
Unit = "postfix-reload.service";
|
|
|
|
};
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services."postfix-reload" = {
|
|
|
|
description = "Reloads postfix config, e.g. after TLS certs change, notified by watcher-acme-ssl-file.path";
|
|
|
|
documentation = [ "systemd.path(5)" ];
|
|
|
|
requires = [ "postfix.service" ];
|
|
|
|
after = [ "postfix.service" ];
|
|
|
|
startLimitIntervalSec = 10;
|
|
|
|
startLimitBurst = 5;
|
|
|
|
serviceConfig.Type = "oneshot";
|
|
|
|
script = ''
|
|
|
|
${pkgs.systemd}/bin/systemctl reload postfix
|
|
|
|
'';
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
services.mailman = {
|
|
|
|
enable = true;
|
|
|
|
serve.enable = true;
|
|
|
|
hyperkitty.enable = true;
|
2024-05-08 17:47:47 +00:00
|
|
|
webHosts = [ "list.${config.pub-solar-os.networking.domain}" ];
|
2023-10-28 22:31:09 +00:00
|
|
|
siteOwner = "admins@pub.solar";
|
|
|
|
};
|
|
|
|
|
|
|
|
# TODO add django-keycloak as auth provider
|
|
|
|
# https://django-keycloak.readthedocs.io/en/latest/
|
|
|
|
## Extend settings.py directly since this can't be done via JSON
|
|
|
|
## settings (services.mailman.webSettings)
|
|
|
|
#environment.etc."mailman3/settings.py".text = ''
|
|
|
|
# INSTALLED_APPS.extend([
|
|
|
|
# "allauth.socialaccount.providers.github",
|
|
|
|
# "allauth.socialaccount.providers.gitlab"
|
|
|
|
# ])
|
|
|
|
#'';
|
2023-11-05 21:54:09 +00:00
|
|
|
|
2023-11-18 21:28:12 +00:00
|
|
|
services.restic.backups.mailman-droppie = {
|
2023-11-05 21:54:09 +00:00
|
|
|
paths = [
|
|
|
|
"/var/lib/mailman"
|
|
|
|
"/var/lib/mailman-web/mailman-web.db"
|
2023-11-06 21:20:29 +00:00
|
|
|
"/var/lib/mailman-web/settings_local.json"
|
2023-11-05 21:54:09 +00:00
|
|
|
"/var/lib/postfix/conf/aliases.db"
|
|
|
|
];
|
2023-11-05 22:47:06 +00:00
|
|
|
timerConfig = {
|
|
|
|
OnCalendar = "*-*-* 02:00:00 Etc/UTC";
|
|
|
|
# droppie will be offline if nachtigall misses the timer
|
|
|
|
Persistent = false;
|
|
|
|
};
|
|
|
|
initialize = true;
|
|
|
|
passwordFile = config.age.secrets."restic-repo-droppie".path;
|
2023-11-06 21:58:48 +00:00
|
|
|
repository = "sftp:yule@droppie.b12f.io:/media/internal/pub.solar";
|
2024-04-22 18:06:49 +00:00
|
|
|
pruneOpts = [
|
|
|
|
"--keep-daily 7"
|
|
|
|
"--keep-weekly 4"
|
|
|
|
"--keep-monthly 3"
|
|
|
|
];
|
2023-11-05 21:54:09 +00:00
|
|
|
};
|
2023-11-18 21:28:12 +00:00
|
|
|
|
|
|
|
services.restic.backups.mailman-storagebox = {
|
|
|
|
paths = [
|
|
|
|
"/var/lib/mailman"
|
|
|
|
"/var/lib/mailman-web/mailman-web.db"
|
|
|
|
"/var/lib/mailman-web/settings_local.json"
|
|
|
|
"/var/lib/postfix/conf/aliases.db"
|
|
|
|
];
|
|
|
|
timerConfig = {
|
2023-11-18 21:41:48 +00:00
|
|
|
OnCalendar = "*-*-* 04:15:00 Etc/UTC";
|
2023-11-18 21:28:12 +00:00
|
|
|
};
|
|
|
|
initialize = true;
|
|
|
|
passwordFile = config.age.secrets."restic-repo-storagebox".path;
|
|
|
|
repository = "sftp:u377325@u377325.your-storagebox.de:/backups";
|
2024-04-22 18:06:49 +00:00
|
|
|
pruneOpts = [
|
|
|
|
"--keep-daily 7"
|
|
|
|
"--keep-weekly 4"
|
|
|
|
"--keep-monthly 3"
|
|
|
|
];
|
2023-11-18 21:28:12 +00:00
|
|
|
};
|
2023-10-28 22:31:09 +00:00
|
|
|
}
|