Loading nixos/modules/services/logging/logrotate.nix +13 −7 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ with lib; let cfg = config.services.logrotate; pathOpts = { pathOpts = { name, ... }: { options = { enable = mkOption { type = types.bool; Loading @@ -16,10 +16,17 @@ let ''; }; path = mkOption { name = mkOption { type = types.str; internal = true; }; path = mkOption { type = with types; either str (listOf str); description = '' The path to log files to be rotated. Spaces are allowed and normal shell quoting rules apply, with ', ", and \ characters supported. ''; }; Loading Loading @@ -74,6 +81,7 @@ let }; }; config.name = name; config.extraConfig = '' missingok notifempty Loading @@ -82,7 +90,7 @@ let mkConf = pathOpts: '' # generated by NixOS using the `services.logrotate.paths.${pathOpts.name}` attribute set "${pathOpts.path}" { ${concatMapStringsSep " " (path: ''"${path}"'') (toList pathOpts.path)} { ${optionalString (pathOpts.user != null || pathOpts.group != null) "su ${pathOpts.user} ${pathOpts.group}"} ${pathOpts.frequency} rotate ${toString pathOpts.keep} Loading @@ -90,7 +98,7 @@ let } ''; paths = sortProperties (mapAttrsToList (name: pathOpts: pathOpts // { name = name; }) (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 ])); in Loading Loading @@ -156,13 +164,11 @@ in description = "Logrotate Service"; wantedBy = [ "multi-user.target" ]; startAt = "hourly"; script = '' exec ${pkgs.logrotate}/sbin/logrotate ${configFile} ''; serviceConfig = { Restart = "no"; User = "root"; ExecStart = "${pkgs.logrotate}/sbin/logrotate ${configFile}"; }; }; }; Loading Loading
nixos/modules/services/logging/logrotate.nix +13 −7 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ with lib; let cfg = config.services.logrotate; pathOpts = { pathOpts = { name, ... }: { options = { enable = mkOption { type = types.bool; Loading @@ -16,10 +16,17 @@ let ''; }; path = mkOption { name = mkOption { type = types.str; internal = true; }; path = mkOption { type = with types; either str (listOf str); description = '' The path to log files to be rotated. Spaces are allowed and normal shell quoting rules apply, with ', ", and \ characters supported. ''; }; Loading Loading @@ -74,6 +81,7 @@ let }; }; config.name = name; config.extraConfig = '' missingok notifempty Loading @@ -82,7 +90,7 @@ let mkConf = pathOpts: '' # generated by NixOS using the `services.logrotate.paths.${pathOpts.name}` attribute set "${pathOpts.path}" { ${concatMapStringsSep " " (path: ''"${path}"'') (toList pathOpts.path)} { ${optionalString (pathOpts.user != null || pathOpts.group != null) "su ${pathOpts.user} ${pathOpts.group}"} ${pathOpts.frequency} rotate ${toString pathOpts.keep} Loading @@ -90,7 +98,7 @@ let } ''; paths = sortProperties (mapAttrsToList (name: pathOpts: pathOpts // { name = name; }) (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 ])); in Loading Loading @@ -156,13 +164,11 @@ in description = "Logrotate Service"; wantedBy = [ "multi-user.target" ]; startAt = "hourly"; script = '' exec ${pkgs.logrotate}/sbin/logrotate ${configFile} ''; serviceConfig = { Restart = "no"; User = "root"; ExecStart = "${pkgs.logrotate}/sbin/logrotate ${configFile}"; }; }; }; Loading