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;
|
|
|
|
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.logrotate = {
|
2020-05-12 21:55:09 +01:00
|
|
|
enable = mkEnableOption "the logrotate systemd service";
|
2010-04-29 19:54:08 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkOption {
|
|
|
|
default = "";
|
2014-10-16 07:20:43 +01:00
|
|
|
type = types.lines;
|
2010-04-29 19:54:08 +01:00
|
|
|
description = ''
|
|
|
|
The contents of the logrotate config file
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2014-07-10 12:11:35 +01:00
|
|
|
systemd.services.logrotate = {
|
|
|
|
description = "Logrotate Service";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
startAt = "*-*-* *:05:00";
|
|
|
|
|
|
|
|
serviceConfig.Restart = "no";
|
|
|
|
serviceConfig.User = "root";
|
|
|
|
script = ''
|
|
|
|
exec ${pkgs.logrotate}/sbin/logrotate ${configFile}
|
|
|
|
'';
|
|
|
|
};
|
2010-04-29 19:54:08 +01:00
|
|
|
};
|
|
|
|
}
|