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.";
|
||||
};
|
||||
|
||||
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
|
||||
|
||||
config = mkIf config.services.postfix.enable {
|
||||
config = mkIf config.services.postfix.enable (mkMerge [
|
||||
{
|
||||
|
||||
environment = {
|
||||
etc = singleton
|
||||
@ -411,9 +424,9 @@ in
|
||||
Type = "forking";
|
||||
Restart = "always";
|
||||
PIDFile = "/var/lib/postfix/queue/pid/master.pid";
|
||||
ExecStart = "${pkgs.postfix}/bin/postfix -c /etc/postfix start";
|
||||
ExecStop = "${pkgs.postfix}/bin/postfix -c /etc/postfix stop";
|
||||
ExecReload = "${pkgs.postfix}/bin/postfix -c /etc/postfix reload";
|
||||
ExecStart = "${pkgs.postfix}/bin/postfix start";
|
||||
ExecStop = "${pkgs.postfix}/bin/postfix stop";
|
||||
ExecReload = "${pkgs.postfix}/bin/postfix reload";
|
||||
};
|
||||
|
||||
preStart = ''
|
||||
@ -429,18 +442,14 @@ in
|
||||
mkdir -p /var/lib/postfix/conf
|
||||
ln -sf ${mainCfFile} /var/lib/postfix/conf/main.cf
|
||||
ln -sf ${masterCfFile} /var/lib/postfix/conf/master.cf
|
||||
${optionalString haveAliases ''
|
||||
ln -sf ${aliasesFile} /var/lib/postfix/conf/aliases
|
||||
postalias /var/lib/postfix/conf/aliases
|
||||
''}
|
||||
${optionalString haveTransport ''
|
||||
${pkgs.coreutils}/bin/ln -sf ${transportFile} /var/lib/postfix/conf/transport
|
||||
${pkgs.postfix}/bin/postmap /var/lib/postfix/conf/transport
|
||||
''}
|
||||
${optionalString haveVirtual ''
|
||||
ln -sf ${virtualFile} /var/lib/postfix/conf/virtual
|
||||
postmap /var/lib/postfix/conf/virtual
|
||||
''}
|
||||
${concatStringsSep "\n" (mapAttrsToList (to: from: ''
|
||||
ln -sf ${from} /var/lib/postfix/conf/${to}
|
||||
postalias /var/lib/postfix/conf/${to}
|
||||
'') cfg.aliasFiles)}
|
||||
${concatStringsSep "\n" (mapAttrsToList (to: from: ''
|
||||
ln -sf ${from} /var/lib/postfix/conf/${to}
|
||||
postmap /var/lib/postfix/conf/${to}
|
||||
'') cfg.mapFiles)}
|
||||
|
||||
mkdir -p /var/spool/mail
|
||||
chown root:root /var/spool/mail
|
||||
@ -448,7 +457,17 @@ in
|
||||
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