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
|
||||
|
||||
concatMapLines = f: l: lib.concatStringsSep "\n" (map f l);
|
||||
|
||||
cfg = config.services.mlmmj;
|
||||
stateDir = "/var/lib/mlmmj";
|
||||
spoolDir = "/var/spool/mlmmj";
|
||||
|
@ -16,13 +18,24 @@ let
|
|||
listAddress = domain: list: "${list}@${domain}";
|
||||
customHeaders = domain: list: [ "List-Id: ${list}" "Reply-To: ${list}@${domain}" ];
|
||||
footer = domain: list: "To unsubscribe send a mail to ${list}+unsubscribe@${domain}";
|
||||
createList = d: l: ''
|
||||
${pkgs.coreutils}/bin/mkdir -p ${listCtl d l}
|
||||
echo ${listAddress d l} > ${listCtl d l}/listaddress
|
||||
echo "${lib.concatStringsSep "\n" (customHeaders d l)}" > ${listCtl d l}/customheaders
|
||||
echo ${footer d l} > ${listCtl d l}/footer
|
||||
echo ${subjectPrefix l} > ${listCtl d l}/prefix
|
||||
'';
|
||||
createList = d: l:
|
||||
let ctlDir = listCtl d l; in
|
||||
''
|
||||
for DIR in incoming queue queue/discarded archive text subconf unsubconf \
|
||||
bounce control moderation subscribers.d digesters.d requeue \
|
||||
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
|
||||
|
||||
{
|
||||
|
@ -63,6 +76,16 @@ in
|
|||
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
|
||||
'';
|
||||
|
||||
extraAliases = concatMapStrings (alias cfg.listDomain) cfg.mailLists;
|
||||
extraAliases = concatMapLines (alias cfg.listDomain) cfg.mailLists;
|
||||
|
||||
extraConfig = ''
|
||||
transport_maps = hash:${stateDir}/transports
|
||||
|
@ -107,17 +130,15 @@ in
|
|||
system.activationScripts.mlmmj = ''
|
||||
${pkgs.coreutils}/bin/mkdir -p ${stateDir} ${spoolDir}/${cfg.listDomain}
|
||||
${pkgs.coreutils}/bin/chown -R ${cfg.user}:${cfg.group} ${spoolDir}
|
||||
${lib.concatMapStrings (createList cfg.listDomain) cfg.mailLists}
|
||||
echo ${lib.concatMapStrings (virtual cfg.listDomain) cfg.mailLists} > ${stateDir}/virtuals
|
||||
echo ${lib.concatMapStrings (transport cfg.listDomain) cfg.mailLists} > ${stateDir}/transports
|
||||
${concatMapLines (createList cfg.listDomain) cfg.mailLists}
|
||||
echo "${concatMapLines (virtual cfg.listDomain) cfg.mailLists}" > ${stateDir}/virtuals
|
||||
echo "${concatMapLines (transport cfg.listDomain) cfg.mailLists}" > ${stateDir}/transports
|
||||
${pkgs.postfix}/bin/postmap ${stateDir}/virtuals
|
||||
${pkgs.postfix}/bin/postmap ${stateDir}/transports
|
||||
'';
|
||||
|
||||
systemd.services."mlmmj-maintd" = {
|
||||
description = "mlmmj maintenance daemon";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
User = cfg.user;
|
||||
Group = cfg.group;
|
||||
|
@ -125,6 +146,11 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
systemd.timers."mlmmj-maintd" = {
|
||||
description = "mlmmj maintenance timer";
|
||||
timerConfig.OnUnitActiveSec = cfg.maintInterval;
|
||||
wantedBy = [ "timers.target" ];
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue