@@ -5,7 +5,7 @@ with lib;
55let
66 cfg = config.services.logrotate;
77
8− pathOpts = {
8+ pathOpts = { name, ... }: {
99 options = {
1010 enable = mkOption {
1111 type = types.bool;
@@ -16,10 +16,17 @@ let
1616 '';
1717 };
1818
19− path = mkOption {
19+ name = mkOption {
2020 type = types.str;
21+ internal = true;
22+ };
23+
24+ path = mkOption {
25+ type = with types; either str (listOf str);
2126 description = ''
2227 The path to log files to be rotated.
28+ Spaces are allowed and normal shell quoting rules apply,
29+ with ', ", and \ characters supported.
2330 '';
2431 };
2532
@@ -74,6 +81,7 @@ let
7481 };
7582 };
7683
84+ config.name = name;
7785 config.extraConfig = ''
7886 missingok
7987 notifempty
@@ -82,7 +90,7 @@ let
8290
8391 mkConf = pathOpts: ''
8492 # generated by NixOS using the `services.logrotate.paths.${pathOpts.name}` attribute set
85− "${pathOpts.path}" {
93+ ${concatMapStringsSep " " (path: ''"${path}"'') (toList pathOpts.path)} {
8694 ${optionalString (pathOpts.user != null || pathOpts.group != null) "su ${pathOpts.user} ${pathOpts.group}"}
8795 ${pathOpts.frequency}
8896 rotate ${toString pathOpts.keep}
@@ -90,7 +98,7 @@ let
9098 }
9199 '';
92100
93− paths = sortProperties (mapAttrsToList (name: pathOpts: pathOpts // { name = name; }) (filterAttrs (_: pathOpts: pathOpts.enable) cfg.paths));
101+ paths = sortProperties (attrValues (filterAttrs (_: pathOpts: pathOpts.enable) cfg.paths));
94102 configFile = pkgs.writeText "logrotate.conf" (concatStringsSep "\n" ((map mkConf paths) ++ [ cfg.extraConfig ]));
95103
96104in
@@ -156,13 +164,11 @@ in
156164 description = "Logrotate Service";
157165 wantedBy = [ "multi-user.target" ];
158166 startAt = "hourly";
159− script = ''
160− exec ${pkgs.logrotate}/sbin/logrotate ${configFile}
161− '';
162167
163168 serviceConfig = {
164169 Restart = "no";
165170 User = "root";
171+ ExecStart = "${pkgs.logrotate}/sbin/logrotate ${configFile}";
166172 };
167173 };
168174 };