nixos/postfix: add options to compile additional maps and aliases
This commit is contained in:
parent
9c502abb1c
commit
1edb62b40a
@ -356,6 +356,18 @@ in
|
|||||||
description = "Extra lines to append to the generated master.cf file.";
|
description = "Extra lines to append to the generated master.cf file.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
aliasFiles = mkOption {
|
||||||
|
type = types.attrsOf types.path;
|
||||||
|
default = {};
|
||||||
|
description = "Aliases' tables to be compiled and placed into /var/lib/postfix/conf.";
|
||||||
|
};
|
||||||
|
|
||||||
|
mapFiles = mkOption {
|
||||||
|
type = types.attrsOf types.path;
|
||||||
|
default = {};
|
||||||
|
description = "Maps to be compiled and placed into /var/lib/postfix/conf.";
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -363,7 +375,8 @@ in
|
|||||||
|
|
||||||
###### implementation
|
###### implementation
|
||||||
|
|
||||||
config = mkIf config.services.postfix.enable {
|
config = mkIf config.services.postfix.enable (mkMerge [
|
||||||
|
{
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
etc = singleton
|
etc = singleton
|
||||||
@ -411,9 +424,9 @@ in
|
|||||||
Type = "forking";
|
Type = "forking";
|
||||||
Restart = "always";
|
Restart = "always";
|
||||||
PIDFile = "/var/lib/postfix/queue/pid/master.pid";
|
PIDFile = "/var/lib/postfix/queue/pid/master.pid";
|
||||||
ExecStart = "${pkgs.postfix}/bin/postfix -c /etc/postfix start";
|
ExecStart = "${pkgs.postfix}/bin/postfix start";
|
||||||
ExecStop = "${pkgs.postfix}/bin/postfix -c /etc/postfix stop";
|
ExecStop = "${pkgs.postfix}/bin/postfix stop";
|
||||||
ExecReload = "${pkgs.postfix}/bin/postfix -c /etc/postfix reload";
|
ExecReload = "${pkgs.postfix}/bin/postfix reload";
|
||||||
};
|
};
|
||||||
|
|
||||||
preStart = ''
|
preStart = ''
|
||||||
@ -429,18 +442,14 @@ in
|
|||||||
mkdir -p /var/lib/postfix/conf
|
mkdir -p /var/lib/postfix/conf
|
||||||
ln -sf ${mainCfFile} /var/lib/postfix/conf/main.cf
|
ln -sf ${mainCfFile} /var/lib/postfix/conf/main.cf
|
||||||
ln -sf ${masterCfFile} /var/lib/postfix/conf/master.cf
|
ln -sf ${masterCfFile} /var/lib/postfix/conf/master.cf
|
||||||
${optionalString haveAliases ''
|
${concatStringsSep "\n" (mapAttrsToList (to: from: ''
|
||||||
ln -sf ${aliasesFile} /var/lib/postfix/conf/aliases
|
ln -sf ${from} /var/lib/postfix/conf/${to}
|
||||||
postalias /var/lib/postfix/conf/aliases
|
postalias /var/lib/postfix/conf/${to}
|
||||||
''}
|
'') cfg.aliasFiles)}
|
||||||
${optionalString haveTransport ''
|
${concatStringsSep "\n" (mapAttrsToList (to: from: ''
|
||||||
${pkgs.coreutils}/bin/ln -sf ${transportFile} /var/lib/postfix/conf/transport
|
ln -sf ${from} /var/lib/postfix/conf/${to}
|
||||||
${pkgs.postfix}/bin/postmap /var/lib/postfix/conf/transport
|
postmap /var/lib/postfix/conf/${to}
|
||||||
''}
|
'') cfg.mapFiles)}
|
||||||
${optionalString haveVirtual ''
|
|
||||||
ln -sf ${virtualFile} /var/lib/postfix/conf/virtual
|
|
||||||
postmap /var/lib/postfix/conf/virtual
|
|
||||||
''}
|
|
||||||
|
|
||||||
mkdir -p /var/spool/mail
|
mkdir -p /var/spool/mail
|
||||||
chown root:root /var/spool/mail
|
chown root:root /var/spool/mail
|
||||||
@ -448,7 +457,17 @@ in
|
|||||||
ln -sf /var/spool/mail /var/
|
ln -sf /var/spool/mail /var/
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
};
|
(mkIf haveAliases {
|
||||||
|
services.postfix.aliasFiles."aliases" = aliasesFile;
|
||||||
|
})
|
||||||
|
(mkIf haveTransport {
|
||||||
|
services.postfix.mapFiles."transport" = transportFile;
|
||||||
|
})
|
||||||
|
(mkIf haveVirtual {
|
||||||
|
services.postfix.mapFiles."virtual" = virtualFile;
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user