Generate mail accounts from a user list.

This commit is contained in:
Kevin Baensch 2019-08-27 16:01:04 +02:00
parent 9f49f3fcf0
commit 51e986da9c
3 changed files with 17 additions and 9 deletions

View file

@ -3,18 +3,19 @@
with lib;
mkIf (elem "mailserver" config.machine.services) {
mailserver = rec {
mailserver = let
mkUser = username: {
name = "${username}@${config.machine.domain}";
value = {
hashedPassword = (fileContents "/secret/${username}.mail");
};
};
in rec {
enable = true;
fqdn = "mail.${config.machine.domain}";
domains = [ config.machine.domain ];
loginAccounts = {
"derped@${config.machine.domain}" = {
hashedPassword = (fileContents /secret/derped.mail);
};
"mailman3@${config.machine.domain}" = {
hashedPassword = (fileContents /secret/mailman3.mail);
};
};
loginAccounts = listToAttrs (map mkUser config.machine.mailAccounts);
# Use Let's Encrypt certificates. Note that this needs to set up a stripped
# down nginx and opens port 80.
certificateScheme = 1;