From 41cb04f793d4f54ab131934cfac8ca857d61c352 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 20 Jul 2012 11:36:09 -0400 Subject: [PATCH] Implement serial-getty@.service --- modules/services/ttys/agetty.nix | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/modules/services/ttys/agetty.nix b/modules/services/ttys/agetty.nix index 42d276c96664..a0e53eeaef46 100644 --- a/modules/services/ttys/agetty.nix +++ b/modules/services/ttys/agetty.nix @@ -21,6 +21,7 @@ with pkgs.lib; ''; }; + # FIXME: not implemented with systemd waitOnMounts = mkOption { default = false; description = '' @@ -56,6 +57,9 @@ with pkgs.lib; config = { + # FIXME: these are mostly copy/pasted from the systemd sources, + # which some small modifications, which is annoying. + # Generate a separate job for each tty. boot.systemd.units."getty@.service".text = '' @@ -70,6 +74,8 @@ with pkgs.lib; Before=getty.target IgnoreOnIsolate=yes + ConditionPathExists=/dev/tty0 + [Service] Environment=TERM=linux Environment=LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive @@ -90,6 +96,39 @@ with pkgs.lib; KillSignal=SIGHUP ''; + boot.systemd.units."serial-getty@.service".text = + '' + [Unit] + Description=Serial Getty on %I + Documentation=man:agetty(8) man:systemd-getty-generator(8) + BindsTo=dev-%i.device + After=dev-%i.device systemd-user-sessions.service plymouth-quit-wait.service + + # If additional gettys are spawned during boot then we should make + # sure that this is synchronized before getty.target, even though + # getty.target didn't actually pull it in. + Before=getty.target + IgnoreOnIsolate=yes + + [Service] + Environment=TERM=linux + Environment=LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive + ExecStart=@${pkgs.utillinux}/sbin/agetty agetty --login-program ${pkgs.shadow}/bin/login %I 115200,38400,9600 + Type=idle + Restart=always + RestartSec=0 + UtmpIdentifier=%I + TTYPath=/dev/%I + TTYReset=yes + TTYVHangup=yes + KillMode=process + IgnoreSIGPIPE=no + + # Some login implementations ignore SIGTERM, so we send SIGHUP + # instead, to ensure that login terminates cleanly. + KillSignal=SIGHUP + ''; + environment.etc = singleton { # Friendly greeting on the virtual consoles. source = pkgs.writeText "issue" ''