diff options
Diffstat (limited to 'nixos/modules/services/logging/logrotate.nix')
-rw-r--r-- | nixos/modules/services/logging/logrotate.nix | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/nixos/modules/services/logging/logrotate.nix b/nixos/modules/services/logging/logrotate.nix new file mode 100644 index 000000000000..c6c0d2ea2382 --- /dev/null +++ b/nixos/modules/services/logging/logrotate.nix @@ -0,0 +1,38 @@ +{config, pkgs, ...}: + +with pkgs.lib; + +let + cfg = config.services.logrotate; + + configFile = pkgs.writeText "logrotate.conf" + cfg.config; + + cronJob = '' + 5 * * * * root ${pkgs.logrotate}/sbin/logrotate ${configFile} + ''; + +in +{ + options = { + services.logrotate = { + enable = mkOption { + default = false; + description = '' + Enable the logrotate cron job + ''; + }; + + config = mkOption { + default = ""; + description = '' + The contents of the logrotate config file + ''; + }; + }; + }; + + config = mkIf cfg.enable { + services.cron.systemCronJobs = [ cronJob ]; + }; +} |