2014-04-14 15:26:48 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2010-04-29 19:54:08 +01:00
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
with lib;
|
2010-04-29 19:54:08 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.logrotate;
|
|
|
|
|
|
|
|
configFile = pkgs.writeText "logrotate.conf"
|
|
|
|
cfg.config;
|
|
|
|
|
|
|
|
cronJob = ''
|
2010-05-01 14:23:32 +01:00
|
|
|
5 * * * * root ${pkgs.logrotate}/sbin/logrotate ${configFile}
|
2010-04-29 19:54:08 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
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 ];
|
|
|
|
};
|
|
|
|
}
|