nixpkgs/modules/services/ttys/agetty.nix

153 lines
4.2 KiB
Nix
Raw Normal View History

{ config, pkgs, ... }:
with pkgs.lib;
let
issueFile = pkgs.writeText "issue" ''
${config.services.mingetty.greetingLine}
xyzzy6
${config.services.mingetty.helpLine}
'';
in
{
###### interface
options = {
services.mingetty = {
2012-06-18 21:55:27 +00:00
# FIXME
ttys = mkOption {
default =
if pkgs.stdenv.isArm
then [ "ttyS0" ] # presumably an embedded platform such as a plug
else [ "tty1" "tty2" "tty3" "tty4" "tty5" "tty6" ];
description = ''
The list of tty devices on which to start a login prompt.
'';
};
2012-07-20 15:36:09 +00:00
# FIXME: not implemented with systemd
waitOnMounts = mkOption {
default = false;
description = ''
Whether the login prompts on the virtual consoles will be
started before or after all file systems have been mounted. By
default we don't wait, but if for example your /home is on a
separate partition, you may want to turn this on.
'';
};
greetingLine = mkOption {
default = ''<<< Welcome to NixOS ${config.system.nixosVersion} (\m) - \l >>>'';
description = ''
Welcome line printed by mingetty.
'';
};
helpLine = mkOption {
default = "";
description = ''
2012-06-18 21:58:31 +00:00
Help line printed by mingetty below the welcome line.
Used by the installation CD to give some hints on
how to proceed.
'';
};
};
};
###### implementation
config = {
2012-07-20 15:36:09 +00:00
# FIXME: these are mostly copy/pasted from the systemd sources,
# which some small modifications, which is annoying.
# Generate a separate job for each tty.
2012-06-18 21:55:27 +00:00
boot.systemd.units."getty@.service".text =
''
[Unit]
Description=Getty on %I
Documentation=man:agetty(8)
After=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
2012-07-20 15:36:09 +00:00
ConditionPathExists=/dev/tty0
2012-06-18 21:55:27 +00:00
[Service]
Environment=TERM=linux
Environment=LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive
ExecStart=@${pkgs.utillinux}/sbin/agetty agetty --noclear -f ${issueFile} --login-program ${pkgs.shadow}/bin/login %I 38400
2012-06-18 21:55:27 +00:00
Type=idle
Restart=always
RestartSec=0
UtmpIdentifier=%I
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes
2012-07-20 21:39:05 +00:00
TTYVTDisallocate=yes # set to no to prevent clearing the screen
2012-06-18 21:55:27 +00:00
KillMode=process
IgnoreSIGPIPE=no
# Some login implementations ignore SIGTERM, so we send SIGHUP
# instead, to ensure that login terminates cleanly.
KillSignal=SIGHUP
'';
2012-07-20 15:36:09 +00:00
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 = issueFile;
target = "issue";
};
2012-06-18 21:58:31 +00:00
};
}