From 6419172bc2c3b07c6769479a7cfc07806143e32b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 19 Jul 2012 17:32:50 -0400 Subject: [PATCH] journald: enable logging to the console --- modules/system/boot/systemd.nix | 43 +++++++++++++++++++----- modules/testing/test-instrumentation.nix | 11 ++---- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/modules/system/boot/systemd.nix b/modules/system/boot/systemd.nix index d7684c7ecb26..2b32c94262ed 100644 --- a/modules/system/boot/systemd.nix +++ b/modules/system/boot/systemd.nix @@ -295,21 +295,21 @@ let units = pkgs.runCommand "units" { preferLocalBuild = true; } '' - mkdir -p $out/system + mkdir -p $out for i in ${toString upstreamUnits}; do fn=${systemd}/example/systemd/system/$i [ -e $fn ] if [ -L $fn ]; then - cp -pd $fn $out/system/ + cp -pd $fn $out/ else - ln -s $fn $out/system + ln -s $fn $out/ fi done for i in ${toString upstreamWants}; do fn=${systemd}/example/systemd/system/$i [ -e $fn ] - x=$out/system/$(basename $fn) + x=$out/$(basename $fn) mkdir $x for i in $fn/*; do y=$x/$(basename $i) @@ -319,16 +319,16 @@ let done for i in ${toString nixosUnits}; do - cp $i/* $out/system + cp $i/* $out/ done ${concatStrings (mapAttrsToList (name: unit: concatMapStrings (name2: '' - mkdir -p $out/system/${name2}.wants - ln -sfn ../${name} $out/system/${name2}.wants/ + mkdir -p $out/${name2}.wants + ln -sfn ../${name} $out/${name2}.wants/ '') unit.wantedBy) cfg.units)} - ln -s ${cfg.defaultUnit} $out/system/default.target + ln -s ${cfg.defaultUnit} $out/default.target ''; # */ in @@ -373,6 +373,18 @@ in type = types.uniq types.string; description = "Default unit started when the system boots."; }; + + services.journald.logKernelMessages = mkOption { + default = true; + type = types.bool; + description = "Whether to log kernel messages."; + }; + + services.journald.console = mkOption { + default = ""; + type = types.uniq types.string; + description = "If non-empty, write log messages to the specified TTY device. Defaults to /dev/console."; + }; }; @@ -389,7 +401,20 @@ in environment.etc = [ { source = units; - target = "systemd"; + target = "systemd/system"; + } + { source = pkgs.writeText "journald.conf" + '' + [Journal] + ${optionalString (config.services.journald.console != "") '' + ForwardToConsole=yes + TTYPath=${config.services.journald.console} + ''} + ${optionalString config.services.journald.logKernelMessages '' + ImportKernel=yes + ''} + ''; + target = "systemd/journald.conf"; } ]; diff --git a/modules/testing/test-instrumentation.nix b/modules/testing/test-instrumentation.nix index ce9c1cea7431..c81f6eaac65a 100644 --- a/modules/testing/test-instrumentation.nix +++ b/modules/testing/test-instrumentation.nix @@ -66,15 +66,8 @@ with pkgs.lib; # `xwininfo' is used by the test driver to query open windows. environment.systemPackages = [ pkgs.xorg.xwininfo ]; - # Send all of /var/log/messages to the serial port. - services.syslogd.extraConfig = "*.* /dev/ttyS0"; - - # Disable "-- MARK --" messages. These prevent hanging tests from - # being killed after 1 hour of silence. - services.syslogd.extraParams = [ "-m 0" ]; - - # Don't run klogd. Kernel messages appear on the serial console anyway. - jobs.klogd.startOn = mkOverride 50 ""; + # Log everything to the serial console. + services.journald.console = "/dev/console"; # Prevent tests from accessing the Internet. networking.defaultGateway = mkOverride 150 "";