logrotate: prepend extraConfig instead of postpending it

logrotate global options only affect rules following them - as such,
services.logrotate.extraConfig being added last makes the option only
useful for adding new paths but not for setting global options (e.g.
'dateext' so all logs are rotate with a date suffix).

Moving this first solves this problem, and we can then use this instead
of default paths config to append missingok/notifempty.
This commit is contained in:
Dominique Martinet 2022-02-11 17:27:06 +09:00
parent c7618fbd9b
commit c132bfaa19

View File

@ -84,10 +84,6 @@ let
}; };
config.name = name; config.name = name;
config.extraConfig = ''
missingok
notifempty
'';
}; };
mkConf = pathOpts: '' mkConf = pathOpts: ''
@ -101,7 +97,11 @@ let
''; '';
paths = sortProperties (attrValues (filterAttrs (_: pathOpts: pathOpts.enable) cfg.paths)); paths = sortProperties (attrValues (filterAttrs (_: pathOpts: pathOpts.enable) cfg.paths));
configFile = pkgs.writeText "logrotate.conf" (concatStringsSep "\n" ((map mkConf paths) ++ [ cfg.extraConfig ])); configFile = pkgs.writeText "logrotate.conf" (
concatStringsSep "\n" (
[ "missingok" "notifempty" cfg.extraConfig ] ++ (map mkConf paths)
)
);
in in
{ {