summary refs log tree commit diff
path: root/nixos/modules/services/logging/klogd.nix
blob: 8d371c161eb182f48b4a19535edfa9f87ca46163 (plain) (blame)
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
{ config, lib, pkgs, ... }:

with lib;

{
  ###### interface

  options = {

    services.klogd.enable = mkOption {
      type = types.bool;
      default = versionOlder (getVersion config.boot.kernelPackages.kernel) "3.5";
      defaultText = literalExpression ''versionOlder (getVersion config.boot.kernelPackages.kernel) "3.5"'';
      description = ''
        Whether to enable klogd, the kernel log message processing
        daemon.  Since systemd handles logging of kernel messages on
        Linux 3.5 and later, this is only useful if you're running an
        older kernel.
      '';
    };

  };


  ###### implementation

  config = mkIf config.services.klogd.enable {
    systemd.services.klogd = {
      description = "Kernel Log Daemon";
      wantedBy = [ "multi-user.target" ];
      path = [ pkgs.sysklogd ];
      unitConfig.ConditionVirtualization = "!systemd-nspawn";
      script =
        "klogd -c 1 -2 -n " +
        "-k $(dirname $(readlink -f /run/booted-system/kernel))/System.map";
    };
  };
}