nixos/mlmmj: fix newline problems with multiple lists
- Insert newlines into list configurations - Move list maintence to a timer - Create missing directories at profile activation
This commit is contained in:
parent
71f7de9185
commit
634b040373
@ -4,6 +4,8 @@ with lib;
|
|||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
concatMapLines = f: l: lib.concatStringsSep "\n" (map f l);
|
||||||
|
|
||||||
cfg = config.services.mlmmj;
|
cfg = config.services.mlmmj;
|
||||||
stateDir = "/var/lib/mlmmj";
|
stateDir = "/var/lib/mlmmj";
|
||||||
spoolDir = "/var/spool/mlmmj";
|
spoolDir = "/var/spool/mlmmj";
|
||||||
@ -16,13 +18,24 @@ let
|
|||||||
listAddress = domain: list: "${list}@${domain}";
|
listAddress = domain: list: "${list}@${domain}";
|
||||||
customHeaders = domain: list: [ "List-Id: ${list}" "Reply-To: ${list}@${domain}" ];
|
customHeaders = domain: list: [ "List-Id: ${list}" "Reply-To: ${list}@${domain}" ];
|
||||||
footer = domain: list: "To unsubscribe send a mail to ${list}+unsubscribe@${domain}";
|
footer = domain: list: "To unsubscribe send a mail to ${list}+unsubscribe@${domain}";
|
||||||
createList = d: l: ''
|
createList = d: l:
|
||||||
${pkgs.coreutils}/bin/mkdir -p ${listCtl d l}
|
let ctlDir = listCtl d l; in
|
||||||
echo ${listAddress d l} > ${listCtl d l}/listaddress
|
''
|
||||||
echo "${lib.concatStringsSep "\n" (customHeaders d l)}" > ${listCtl d l}/customheaders
|
for DIR in incoming queue queue/discarded archive text subconf unsubconf \
|
||||||
echo ${footer d l} > ${listCtl d l}/footer
|
bounce control moderation subscribers.d digesters.d requeue \
|
||||||
echo ${subjectPrefix l} > ${listCtl d l}/prefix
|
nomailsubs.d
|
||||||
'';
|
do
|
||||||
|
mkdir -p '${listDir d l}'/"$DIR"
|
||||||
|
done
|
||||||
|
${pkgs.coreutils}/bin/mkdir -p ${ctlDir}
|
||||||
|
echo ${listAddress d l} > '${ctlDir}/listaddress'
|
||||||
|
[ ! -e ${ctlDir}/customheaders ] && \
|
||||||
|
echo "${lib.concatStringsSep "\n" (customHeaders d l)}" > '${ctlDir}/customheaders'
|
||||||
|
[ ! -e ${ctlDir}/footer ] && \
|
||||||
|
echo ${footer d l} > '${ctlDir}/footer'
|
||||||
|
[ ! -e ${ctlDir}/prefix ] && \
|
||||||
|
echo ${subjectPrefix l} > '${ctlDir}/prefix'
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -63,6 +76,16 @@ in
|
|||||||
description = "The collection of hosted maillists";
|
description = "The collection of hosted maillists";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
maintInterval = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "20min";
|
||||||
|
description = ''
|
||||||
|
Time interval between mlmmj-maintd runs, see
|
||||||
|
<citerefentry><refentrytitle>systemd.time</refentrytitle>
|
||||||
|
<manvolnum>7</manvolnum></citerefentry> for format information.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -93,7 +116,7 @@ in
|
|||||||
mlmmj unix - n n - - pipe flags=ORhu user=mlmmj argv=${pkgs.mlmmj}/bin/mlmmj-receive -F -L ${spoolDir}/$nexthop
|
mlmmj unix - n n - - pipe flags=ORhu user=mlmmj argv=${pkgs.mlmmj}/bin/mlmmj-receive -F -L ${spoolDir}/$nexthop
|
||||||
'';
|
'';
|
||||||
|
|
||||||
extraAliases = concatMapStrings (alias cfg.listDomain) cfg.mailLists;
|
extraAliases = concatMapLines (alias cfg.listDomain) cfg.mailLists;
|
||||||
|
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
transport_maps = hash:${stateDir}/transports
|
transport_maps = hash:${stateDir}/transports
|
||||||
@ -107,17 +130,15 @@ in
|
|||||||
system.activationScripts.mlmmj = ''
|
system.activationScripts.mlmmj = ''
|
||||||
${pkgs.coreutils}/bin/mkdir -p ${stateDir} ${spoolDir}/${cfg.listDomain}
|
${pkgs.coreutils}/bin/mkdir -p ${stateDir} ${spoolDir}/${cfg.listDomain}
|
||||||
${pkgs.coreutils}/bin/chown -R ${cfg.user}:${cfg.group} ${spoolDir}
|
${pkgs.coreutils}/bin/chown -R ${cfg.user}:${cfg.group} ${spoolDir}
|
||||||
${lib.concatMapStrings (createList cfg.listDomain) cfg.mailLists}
|
${concatMapLines (createList cfg.listDomain) cfg.mailLists}
|
||||||
echo ${lib.concatMapStrings (virtual cfg.listDomain) cfg.mailLists} > ${stateDir}/virtuals
|
echo "${concatMapLines (virtual cfg.listDomain) cfg.mailLists}" > ${stateDir}/virtuals
|
||||||
echo ${lib.concatMapStrings (transport cfg.listDomain) cfg.mailLists} > ${stateDir}/transports
|
echo "${concatMapLines (transport cfg.listDomain) cfg.mailLists}" > ${stateDir}/transports
|
||||||
${pkgs.postfix}/bin/postmap ${stateDir}/virtuals
|
${pkgs.postfix}/bin/postmap ${stateDir}/virtuals
|
||||||
${pkgs.postfix}/bin/postmap ${stateDir}/transports
|
${pkgs.postfix}/bin/postmap ${stateDir}/transports
|
||||||
'';
|
'';
|
||||||
|
|
||||||
systemd.services."mlmmj-maintd" = {
|
systemd.services."mlmmj-maintd" = {
|
||||||
description = "mlmmj maintenance daemon";
|
description = "mlmmj maintenance daemon";
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
User = cfg.user;
|
User = cfg.user;
|
||||||
Group = cfg.group;
|
Group = cfg.group;
|
||||||
@ -125,6 +146,11 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.timers."mlmmj-maintd" = {
|
||||||
|
description = "mlmmj maintenance timer";
|
||||||
|
timerConfig.OnUnitActiveSec = cfg.maintInterval;
|
||||||
|
wantedBy = [ "timers.target" ];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user