nixos-selfhost/mail.nix

73 lines
2 KiB
Nix
Raw Normal View History

2024-07-02 09:26:34 +02:00
{mailserver, ...}: let
2024-04-09 14:23:32 +02:00
domain = "sondell.org";
2024-07-02 09:26:34 +02:00
fqdn = "mail.${domain}";
mailDirectory = "/var/vmail";
dkimKeyDirectory = "/var/dkim";
in {
2024-04-04 15:05:25 +02:00
imports = [
mailserver
];
2024-07-02 09:26:34 +02:00
services.restic.backups = {
2024-11-26 12:45:00 +01:00
"mail" = {
passwordFile = "/etc/nixos/.secrets/restic_pw";
repository = "sftp:Glenn@nas:/home/back/mail/restic";
initialize = true;
paths = [
mailDirectory
# dkimKeyDirectory
];
user = "root";
timerConfig.OnCalendar = "02:05";
pruneOpts = [
"--keep-daily 10"
"--keep-weekly 5"
"--keep-monthly 12"
"--keep-yearly 75"
];
};
2024-07-02 09:26:34 +02:00
};
2024-11-26 12:45:00 +01:00
2024-04-04 15:05:25 +02:00
mailserver = {
enable = true;
2024-07-02 09:26:34 +02:00
inherit mailDirectory dkimKeyDirectory;
2024-04-09 14:23:32 +02:00
fqdn = fqdn;
2024-07-02 09:26:34 +02:00
domains = [domain];
vmailGroupName = "backup";
2024-04-04 15:05:25 +02:00
# A list of all login accounts. To create the password hashes, use
# cat .secrets/nextadminpw | nix-shell -p mkpasswd --run 'mkpasswd -sm bcrypt' > .secrets/mailpw.hash
2024-04-20 10:50:26 +02:00
# echo apassword | nix-shell -p mkpasswd --run 'mkpasswd -sm bcrypt' > .secrets/gilbertmailpw.hash
2024-04-04 15:05:25 +02:00
loginAccounts = {
"admin@sondell.org" = {
hashedPasswordFile = "/etc/nixos/.secrets/mailpw.hash";
aliases = ["info@sondell.org"];
};
2024-04-15 13:59:59 +02:00
"glenn@sondell.org" = {
hashedPasswordFile = "/etc/nixos/.secrets/mailpw.hash";
};
2024-04-20 10:50:26 +02:00
"gilbert@sondell.org" = {
hashedPasswordFile = "/etc/nixos/.secrets/gilbertmailpw.hash";
};
2024-04-04 15:05:25 +02:00
};
# Use Let's Encrypt certificates. Note that this needs to set up a stripped
# down nginx and opens port 80.
certificateScheme = "acme-nginx";
};
2024-04-09 14:23:32 +02:00
services.roundcube = {
2024-07-02 09:26:34 +02:00
enable = true;
# this is the url of the vhost, not necessarily the same as the fqdn of
# the mailserver
hostName = "webmail.${domain}";
extraConfig = ''
# starttls needed for authentication, so the fqdn required to match
# the certificate
$config['smtp_server'] = "tls://${fqdn}";
$config['smtp_user'] = "%u";
$config['smtp_pass'] = "%p";
'';
2024-04-09 14:23:32 +02:00
};
2024-04-04 15:05:25 +02:00
}