summaryrefslogtreecommitdiff
path: root/modules/syslog.nix
blob: f42c237390174052b00a4e2e7312df4fd12c5745 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{ lib, config, ... }:

let cfg = config.this.syslog;
in
{
  options = {
    this.syslog.enable = lib.mkEnableOption "syslogger";
  };

  config = lib.mkIf cfg.enable {
    services.rsyslogd = {
      enable = true;
      defaultConfig = builtins.readFile ./rsyslogd.conf;
    };
    services.logrotate = {
      enable = true;
      settings = {
        header = {
          create = "0640 root adm";
          missingok = true;
          notifempty = true;
          frequency = "weekly";
          rotate = 4;
          compress = true;
          delaycompress = true;
          minsize = "1M";
        };
        "rsyslogd" = {
          files = [
            "/var/log/syslog"
            "/var/log/mail.log"
            "/var/log/kern.log"
            "/var/log/auth.log"
            "/var/log/user.log"
            "/var/log/cron.log"
          ];
          sharedscripts = true;
          postrotate = "systemctl kill -s HUP syslog.service";
        };
      };
    };
  };
}