Add alias to mail accounts.
Automatically add fqdn as mail alias.
This commit is contained in:
parent
a80b06b881
commit
7d70e000ce
4 changed files with 11 additions and 8 deletions
|
@ -10,7 +10,7 @@ with lib;
|
||||||
config.machine = rec {
|
config.machine = rec {
|
||||||
hostName = "DavidsServer";
|
hostName = "DavidsServer";
|
||||||
administrators = [ { name = "david"; id = 1000; } ];
|
administrators = [ { name = "david"; id = 1000; } ];
|
||||||
mailAccounts = [ "david" ];
|
mailAccounts = [ { name = "david"; aliases = []; } ];
|
||||||
domain = "davids-planet.de";
|
domain = "davids-planet.de";
|
||||||
allowUnfree = true;
|
allowUnfree = true;
|
||||||
conffiles = [
|
conffiles = [
|
||||||
|
|
|
@ -11,7 +11,7 @@ with lib;
|
||||||
config.machine = rec {
|
config.machine = rec {
|
||||||
hostName = "Ophanim";
|
hostName = "Ophanim";
|
||||||
administrators = [ { name = "derped"; id = 1337; } ];
|
administrators = [ { name = "derped"; id = 1337; } ];
|
||||||
mailAccounts = [ "derped" "mailman3" ];
|
mailAccounts = [ { name = "derped"; aliases = [ "postmaster" ]; } { name = "mailman3"; aliases = []; } ];
|
||||||
domain = "ophanim.de";
|
domain = "ophanim.de";
|
||||||
allowUnfree = true;
|
allowUnfree = true;
|
||||||
conffiles = [
|
conffiles = [
|
||||||
|
|
|
@ -48,7 +48,7 @@ with lib;
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
mailAccounts = mkOption {
|
mailAccounts = mkOption {
|
||||||
type = types.listOf types.string;
|
type = types.listOf types.attrs;
|
||||||
description = ''
|
description = ''
|
||||||
List of mail account user names.
|
List of mail account user names.
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -4,16 +4,19 @@ with lib;
|
||||||
|
|
||||||
mkIf (elem "mailserver" config.machine.services) {
|
mkIf (elem "mailserver" config.machine.services) {
|
||||||
mailserver = let
|
mailserver = let
|
||||||
mkUser = username: {
|
domain = config.machine.domain;
|
||||||
name = "${username}@${config.machine.domain}";
|
mkFqdnAlias = name: [ "${name}@${domain}" "${name}@mail.${domain}" ];
|
||||||
|
mkUser = user: rec {
|
||||||
|
name = "${user.name}@${domain}";
|
||||||
value = {
|
value = {
|
||||||
hashedPassword = (fileContents "/secret/${username}.mail");
|
hashedPassword = (fileContents "/secret/${user.name}.mail");
|
||||||
|
aliases = [ "${user.name}@mail.${domain}" ] ++ (flatten (map mkFqdnAlias user.aliases));
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in rec {
|
in rec {
|
||||||
enable = true;
|
enable = true;
|
||||||
fqdn = "mail.${config.machine.domain}";
|
fqdn = "mail.${domain}";
|
||||||
domains = [ config.machine.domain ];
|
domains = [ domain ];
|
||||||
loginAccounts = listToAttrs (map mkUser config.machine.mailAccounts);
|
loginAccounts = listToAttrs (map mkUser config.machine.mailAccounts);
|
||||||
|
|
||||||
# Use Let's Encrypt certificates. Note that this needs to set up a stripped
|
# Use Let's Encrypt certificates. Note that this needs to set up a stripped
|
||||||
|
|
Loading…
Reference in a new issue