From dd1770bf0bb7590635244369ac36c771237aa813 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 5 Oct 2012 13:44:15 -0400 Subject: [PATCH] Enable klogd on Linux < 3.5 On Linux >= 3.5, systemd takes care of logging kernel messages. --- modules/module-list.nix | 2 +- modules/services/logging/klogd.nix | 43 +++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/modules/module-list.nix b/modules/module-list.nix index c1ab8edce403..06c9f8efca70 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -77,7 +77,7 @@ ./services/hardware/udev.nix ./services/hardware/udisks.nix ./services/hardware/upower.nix - #./services/logging/klogd.nix + ./services/logging/klogd.nix ./services/logging/logcheck.nix ./services/logging/logrotate.nix ./services/logging/logstash.nix diff --git a/modules/services/logging/klogd.nix b/modules/services/logging/klogd.nix index 907d83c7a6ac..d7d0bbf89a54 100644 --- a/modules/services/logging/klogd.nix +++ b/modules/services/logging/klogd.nix @@ -1,19 +1,42 @@ { config, pkgs, ... }: -###### implementation +with pkgs.lib; { + ###### interface - jobs.klogd = - { description = "Kernel log daemon"; + options = { - startOn = "started syslogd"; - - path = [ pkgs.sysklogd ]; - - exec = - "klogd -c 1 -2 -n " + - "-k $(dirname $(readlink -f /run/booted-system/kernel))/System.map"; + services.klogd.enable = mkOption { + type = types.bool; + default = 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 { + + jobs.klogd = + { description = "Kernel Log Daemon"; + + wantedBy = [ "multi-user.target" ]; + + path = [ pkgs.sysklogd ]; + + exec = + "klogd -c 1 -2 -n " + + "-k $(dirname $(readlink -f /run/booted-system/kernel))/System.map"; + }; + + }; + }