Add suppport for multiple Domains.
This commit is contained in:
parent
a4fde6972f
commit
bc22db3e1b
5 changed files with 79 additions and 32 deletions
|
@ -5,20 +5,23 @@ with lib;
|
|||
mkIf (elem "mailserver" config.machine.services) {
|
||||
mailserver = let
|
||||
cfg = config.machine;
|
||||
domain = config.machine.domain;
|
||||
domain = cfg.domain;
|
||||
fdomain = (findFirst (s: s.service == "mail") cfg cfg.vHosts).domain;
|
||||
mkFqdnAlias = name: [ "${name}@${domain}" "${name}@${fdomain}" ];
|
||||
mkExDomAlias = name: (map (exDom: "${name}@${exDom}") cfg.extraDomains);
|
||||
mkUser = user: rec {
|
||||
name = "${user.name}@${domain}";
|
||||
value = {
|
||||
hashedPassword = (fileContents "${cfg.secretPath}/${user.name}.mail");
|
||||
aliases = [ "${user.name}@${fdomain}" ] ++ (flatten (map mkFqdnAlias user.aliases));
|
||||
aliases = [ "${user.name}@${fdomain}" ]
|
||||
++ (flatten (map mkFqdnAlias user.aliases))
|
||||
++ (flatten (map mkExDomAlias ([ user.name ] ++ user.aliases)));
|
||||
};
|
||||
};
|
||||
in rec {
|
||||
enable = true;
|
||||
fqdn = fdomain;
|
||||
domains = [ fdomain domain ];
|
||||
domains = ([ fdomain domain ] ++ cfg.extraDomains);
|
||||
loginAccounts = listToAttrs (map mkUser cfg.mailAccounts);
|
||||
|
||||
# Use Let's Encrypt certificates. Note that this needs to set up a stripped
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue