2023-12-18 14:13:57 +00:00
|
|
|
{ config, lib, ... }:
|
2023-11-10 03:10:06 +00:00
|
|
|
let
|
2023-11-16 00:00:11 +00:00
|
|
|
sp = config.selfprivacy;
|
2023-11-10 03:10:06 +00:00
|
|
|
in
|
2023-12-12 04:25:06 +00:00
|
|
|
lib.mkIf sp.modules.simple-nixos-mailserver.enable
|
2023-11-10 03:10:06 +00:00
|
|
|
{
|
2023-12-12 04:25:06 +00:00
|
|
|
fileSystems = lib.mkIf sp.useBinds
|
|
|
|
{
|
|
|
|
"/var/vmail" = {
|
|
|
|
device =
|
|
|
|
"/volumes/${sp.modules.simple-nixos-mailserver.location}/vmail";
|
|
|
|
options = [ "bind" ];
|
|
|
|
};
|
|
|
|
"/var/sieve" = {
|
|
|
|
device =
|
|
|
|
"/volumes/${sp.modules.simple-nixos-mailserver.location}/sieve";
|
|
|
|
options = [ "bind" ];
|
2023-11-10 03:10:06 +00:00
|
|
|
};
|
2023-12-12 04:25:06 +00:00
|
|
|
};
|
2023-11-10 03:10:06 +00:00
|
|
|
|
2023-12-12 04:25:06 +00:00
|
|
|
users.users = {
|
2023-11-10 03:10:06 +00:00
|
|
|
virtualMail = {
|
|
|
|
isNormalUser = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-11-29 04:28:19 +00:00
|
|
|
users.groups.acmereceivers.members = [ "dovecot2" "postfix" "virtualMail" ];
|
|
|
|
|
2023-12-12 04:25:06 +00:00
|
|
|
mailserver = {
|
|
|
|
enable = true;
|
|
|
|
fqdn = sp.domain;
|
|
|
|
domains = [ sp.domain ];
|
2023-11-10 03:10:06 +00:00
|
|
|
|
2023-12-12 04:25:06 +00:00
|
|
|
# A list of all login accounts. To create the password hashes, use
|
|
|
|
# mkpasswd -m sha-512 "super secret password"
|
|
|
|
loginAccounts = {
|
|
|
|
"${sp.username}@${sp.domain}" = {
|
|
|
|
hashedPassword = sp.hashedMasterPassword;
|
|
|
|
sieveScript = ''
|
|
|
|
require ["fileinto", "mailbox"];
|
|
|
|
if header :contains "Chat-Version" "1.0"
|
|
|
|
{
|
|
|
|
fileinto :create "DeltaChat";
|
|
|
|
stop;
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
} // builtins.listToAttrs (builtins.map
|
|
|
|
(user: {
|
|
|
|
name = "${user.username}@${sp.domain}";
|
|
|
|
value = {
|
|
|
|
hashedPassword = user.hashedPassword;
|
2023-11-10 03:10:06 +00:00
|
|
|
sieveScript = ''
|
|
|
|
require ["fileinto", "mailbox"];
|
|
|
|
if header :contains "Chat-Version" "1.0"
|
|
|
|
{
|
|
|
|
fileinto :create "DeltaChat";
|
|
|
|
stop;
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
2023-12-12 04:25:06 +00:00
|
|
|
})
|
|
|
|
sp.users);
|
2023-11-10 03:10:06 +00:00
|
|
|
|
2023-12-12 04:25:06 +00:00
|
|
|
extraVirtualAliases = {
|
|
|
|
"admin@${sp.domain}" = "${sp.username}@${sp.domain}";
|
|
|
|
};
|
2023-11-10 03:10:06 +00:00
|
|
|
|
2023-12-18 14:13:57 +00:00
|
|
|
certificateScheme = "manual";
|
2023-12-12 04:25:06 +00:00
|
|
|
certificateFile = "/var/lib/acme/${sp.domain}/fullchain.pem";
|
|
|
|
keyFile = "/var/lib/acme/${sp.domain}/key.pem";
|
2023-11-10 03:10:06 +00:00
|
|
|
|
2023-12-12 04:25:06 +00:00
|
|
|
# Enable IMAP and POP3
|
|
|
|
enableImap = true;
|
|
|
|
enableImapSsl = true;
|
|
|
|
enablePop3 = false;
|
|
|
|
enablePop3Ssl = false;
|
|
|
|
dkimSelector = "selector";
|
2023-11-10 03:10:06 +00:00
|
|
|
|
2023-12-12 04:25:06 +00:00
|
|
|
# Enable the ManageSieve protocol
|
|
|
|
enableManageSieve = true;
|
2023-11-10 03:10:06 +00:00
|
|
|
|
2023-12-12 04:25:06 +00:00
|
|
|
virusScanning = false;
|
|
|
|
};
|
2023-11-10 03:10:06 +00:00
|
|
|
}
|