From 6c3d21aff953a2f61086fa9dfd22ccaa919910f0 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Tue, 5 Jan 2021 08:25:53 +0000 Subject: nixos/getty: rename from services.mingetty It's been 8.5 years since NixOS used mingetty, but the option was never renamed (despite the file definining the module being renamed in 9f5051b76c1 ("Rename mingetty module to agetty")). I've chosen to rename it to services.getty here, rather than services.agetty, because getty is implemantation-neutral and also the name of the unit that is generated. --- .../installer/cd-dvd/system-tarball-fuloong2f.nix | 2 +- .../installer/cd-dvd/system-tarball-sheevaplug.nix | 2 +- nixos/modules/misc/documentation.nix | 2 +- nixos/modules/module-list.nix | 2 +- nixos/modules/profiles/installation-device.nix | 4 +- nixos/modules/services/ttys/agetty.nix | 117 -------------------- nixos/modules/services/ttys/getty.nix | 121 +++++++++++++++++++++ nixos/modules/virtualisation/lxc-container.nix | 2 +- nixos/tests/login.nix | 2 +- 9 files changed, 129 insertions(+), 125 deletions(-) delete mode 100644 nixos/modules/services/ttys/agetty.nix create mode 100644 nixos/modules/services/ttys/getty.nix diff --git a/nixos/modules/installer/cd-dvd/system-tarball-fuloong2f.nix b/nixos/modules/installer/cd-dvd/system-tarball-fuloong2f.nix index 6d4ba96dba0..8159576a62a 100644 --- a/nixos/modules/installer/cd-dvd/system-tarball-fuloong2f.nix +++ b/nixos/modules/installer/cd-dvd/system-tarball-fuloong2f.nix @@ -104,7 +104,7 @@ in ''; # Some more help text. - services.mingetty.helpLine = + services.getty.helpLine = '' Log in as "root" with an empty password. ${ diff --git a/nixos/modules/installer/cd-dvd/system-tarball-sheevaplug.nix b/nixos/modules/installer/cd-dvd/system-tarball-sheevaplug.nix index 0e67ae7de69..95579f3ca06 100644 --- a/nixos/modules/installer/cd-dvd/system-tarball-sheevaplug.nix +++ b/nixos/modules/installer/cd-dvd/system-tarball-sheevaplug.nix @@ -122,7 +122,7 @@ in device = "/dev/something"; }; - services.mingetty = { + services.getty = { # Some more help text. helpLine = '' Log in as "root" with an empty password. ${ diff --git a/nixos/modules/misc/documentation.nix b/nixos/modules/misc/documentation.nix index fe0263f158f..d81d6c6cb9b 100644 --- a/nixos/modules/misc/documentation.nix +++ b/nixos/modules/misc/documentation.nix @@ -261,7 +261,7 @@ in ++ optionals cfg.doc.enable ([ manual.manualHTML nixos-help ] ++ optionals config.services.xserver.enable [ pkgs.nixos-icons ]); - services.mingetty.helpLine = mkIf cfg.doc.enable ( + services.getty.helpLine = mkIf cfg.doc.enable ( "\nRun 'nixos-help' for the NixOS manual." ); }) diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 5041f2ace22..8fd5d4519fd 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -852,7 +852,7 @@ ./services/torrent/peerflix.nix ./services/torrent/rtorrent.nix ./services/torrent/transmission.nix - ./services/ttys/agetty.nix + ./services/ttys/getty.nix ./services/ttys/gpm.nix ./services/ttys/kmscon.nix ./services/wayland/cage.nix diff --git a/nixos/modules/profiles/installation-device.nix b/nixos/modules/profiles/installation-device.nix index e68ea1b0877..7dc493fb495 100644 --- a/nixos/modules/profiles/installation-device.nix +++ b/nixos/modules/profiles/installation-device.nix @@ -45,10 +45,10 @@ with lib; }; # Automatically log in at the virtual consoles. - services.mingetty.autologinUser = "nixos"; + services.getty.autologinUser = "nixos"; # Some more help text. - services.mingetty.helpLine = '' + services.getty.helpLine = '' The "nixos" and "root" accounts have empty passwords. An ssh daemon is running. You then must set a password diff --git a/nixos/modules/services/ttys/agetty.nix b/nixos/modules/services/ttys/agetty.nix deleted file mode 100644 index d07746be237..00000000000 --- a/nixos/modules/services/ttys/agetty.nix +++ /dev/null @@ -1,117 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; - -let - - autologinArg = optionalString (config.services.mingetty.autologinUser != null) "--autologin ${config.services.mingetty.autologinUser}"; - gettyCmd = extraArgs: "@${pkgs.util-linux}/sbin/agetty agetty --login-program ${pkgs.shadow}/bin/login ${autologinArg} ${extraArgs}"; - -in - -{ - - ###### interface - - options = { - - services.mingetty = { - - autologinUser = mkOption { - type = types.nullOr types.str; - default = null; - description = '' - Username of the account that will be automatically logged in at the console. - If unspecified, a login prompt is shown as usual. - ''; - }; - - greetingLine = mkOption { - type = types.str; - description = '' - Welcome line printed by mingetty. - The default shows current NixOS version label, machine type and tty. - ''; - }; - - helpLine = mkOption { - type = types.lines; - default = ""; - description = '' - Help line printed by mingetty below the welcome line. - Used by the installation CD to give some hints on - how to proceed. - ''; - }; - - serialSpeed = mkOption { - type = types.listOf types.int; - default = [ 115200 57600 38400 9600 ]; - example = [ 38400 9600 ]; - description = '' - Bitrates to allow for agetty's listening on serial ports. Listing more - bitrates gives more interoperability but at the cost of long delays - for getting a sync on the line. - ''; - }; - - }; - - }; - - - ###### implementation - - config = { - # Note: this is set here rather than up there so that changing - # nixos.label would not rebuild manual pages - services.mingetty.greetingLine = mkDefault ''<<< Welcome to NixOS ${config.system.nixos.label} (\m) - \l >>>''; - - systemd.services."getty@" = - { serviceConfig.ExecStart = [ - "" # override upstream default with an empty ExecStart - (gettyCmd "--noclear --keep-baud %I 115200,38400,9600 $TERM") - ]; - restartIfChanged = false; - }; - - systemd.services."serial-getty@" = - let speeds = concatStringsSep "," (map toString config.services.mingetty.serialSpeed); in - { serviceConfig.ExecStart = [ - "" # override upstream default with an empty ExecStart - (gettyCmd "%I ${speeds} $TERM") - ]; - restartIfChanged = false; - }; - - systemd.services."container-getty@" = - { serviceConfig.ExecStart = [ - "" # override upstream default with an empty ExecStart - (gettyCmd "--noclear --keep-baud pts/%I 115200,38400,9600 $TERM") - ]; - restartIfChanged = false; - }; - - systemd.services.console-getty = - { serviceConfig.ExecStart = [ - "" # override upstream default with an empty ExecStart - (gettyCmd "--noclear --keep-baud console 115200,38400,9600 $TERM") - ]; - serviceConfig.Restart = "always"; - restartIfChanged = false; - enable = mkDefault config.boot.isContainer; - }; - - environment.etc.issue = - { # Friendly greeting on the virtual consoles. - source = pkgs.writeText "issue" '' - - ${config.services.mingetty.greetingLine} - ${config.services.mingetty.helpLine} - - ''; - }; - - }; - -} diff --git a/nixos/modules/services/ttys/getty.nix b/nixos/modules/services/ttys/getty.nix new file mode 100644 index 00000000000..68ab8183777 --- /dev/null +++ b/nixos/modules/services/ttys/getty.nix @@ -0,0 +1,121 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + autologinArg = optionalString (config.services.getty.autologinUser != null) "--autologin ${config.services.getty.autologinUser}"; + gettyCmd = extraArgs: "@${pkgs.util-linux}/sbin/agetty agetty --login-program ${pkgs.shadow}/bin/login ${autologinArg} ${extraArgs}"; + +in + +{ + + ###### interface + + imports = [ + (mkRenamedOptionModule [ "services" "mingetty" ] [ "services" "getty" ]) + ]; + + options = { + + services.getty = { + + autologinUser = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + Username of the account that will be automatically logged in at the console. + If unspecified, a login prompt is shown as usual. + ''; + }; + + greetingLine = mkOption { + type = types.str; + description = '' + Welcome line printed by agetty. + The default shows current NixOS version label, machine type and tty. + ''; + }; + + helpLine = mkOption { + type = types.lines; + default = ""; + description = '' + Help line printed by agetty below the welcome line. + Used by the installation CD to give some hints on + how to proceed. + ''; + }; + + serialSpeed = mkOption { + type = types.listOf types.int; + default = [ 115200 57600 38400 9600 ]; + example = [ 38400 9600 ]; + description = '' + Bitrates to allow for agetty's listening on serial ports. Listing more + bitrates gives more interoperability but at the cost of long delays + for getting a sync on the line. + ''; + }; + + }; + + }; + + + ###### implementation + + config = { + # Note: this is set here rather than up there so that changing + # nixos.label would not rebuild manual pages + services.getty.greetingLine = mkDefault ''<<< Welcome to NixOS ${config.system.nixos.label} (\m) - \l >>>''; + + systemd.services."getty@" = + { serviceConfig.ExecStart = [ + "" # override upstream default with an empty ExecStart + (gettyCmd "--noclear --keep-baud %I 115200,38400,9600 $TERM") + ]; + restartIfChanged = false; + }; + + systemd.services."serial-getty@" = + let speeds = concatStringsSep "," (map toString config.services.getty.serialSpeed); in + { serviceConfig.ExecStart = [ + "" # override upstream default with an empty ExecStart + (gettyCmd "%I ${speeds} $TERM") + ]; + restartIfChanged = false; + }; + + systemd.services."container-getty@" = + { serviceConfig.ExecStart = [ + "" # override upstream default with an empty ExecStart + (gettyCmd "--noclear --keep-baud pts/%I 115200,38400,9600 $TERM") + ]; + restartIfChanged = false; + }; + + systemd.services.console-getty = + { serviceConfig.ExecStart = [ + "" # override upstream default with an empty ExecStart + (gettyCmd "--noclear --keep-baud console 115200,38400,9600 $TERM") + ]; + serviceConfig.Restart = "always"; + restartIfChanged = false; + enable = mkDefault config.boot.isContainer; + }; + + environment.etc.issue = + { # Friendly greeting on the virtual consoles. + source = pkgs.writeText "issue" '' + + ${config.services.getty.greetingLine} + ${config.services.getty.helpLine} + + ''; + }; + + }; + +} diff --git a/nixos/modules/virtualisation/lxc-container.nix b/nixos/modules/virtualisation/lxc-container.nix index d4936484018..e47bd59dc01 100644 --- a/nixos/modules/virtualisation/lxc-container.nix +++ b/nixos/modules/virtualisation/lxc-container.nix @@ -11,7 +11,7 @@ with lib; users.users.root.initialHashedPassword = mkOverride 150 ""; # Some more help text. - services.mingetty.helpLine = + services.getty.helpLine = '' Log in as "root" with an empty password. diff --git a/nixos/tests/login.nix b/nixos/tests/login.nix index d36c1a91be4..ce11e1f942a 100644 --- a/nixos/tests/login.nix +++ b/nixos/tests/login.nix @@ -50,7 +50,7 @@ import ./make-test-python.nix ({ pkgs, latestKernel ? false, ... }: with subtest("Virtual console logout"): machine.send_chars("exit\n") machine.wait_until_fails("pgrep -u alice bash") - machine.screenshot("mingetty") + machine.screenshot("getty") with subtest("Check whether ctrl-alt-delete works"): machine.send_key("ctrl-alt-delete") -- cgit 1.4.1