2020-04-24 23:36:52 +00:00
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
|
|
let
|
2021-01-09 10:05:03 +00:00
|
|
|
|
cfg = config.services.getty;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2021-04-13 19:44:15 +00:00
|
|
|
|
baseArgs = [
|
2021-07-21 07:28:18 +00:00
|
|
|
|
"--login-program" "${cfg.loginProgram}"
|
2021-01-09 10:05:03 +00:00
|
|
|
|
] ++ optionals (cfg.autologinUser != null) [
|
|
|
|
|
"--autologin" cfg.autologinUser
|
|
|
|
|
] ++ optionals (cfg.loginOptions != null) [
|
|
|
|
|
"--login-options" cfg.loginOptions
|
2021-04-13 19:44:15 +00:00
|
|
|
|
] ++ cfg.extraArgs;
|
2021-01-09 10:05:03 +00:00
|
|
|
|
|
2021-04-13 19:44:15 +00:00
|
|
|
|
gettyCmd = args:
|
|
|
|
|
"@${pkgs.util-linux}/sbin/agetty agetty ${escapeShellArgs baseArgs} ${args}";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
2021-01-05 17:05:55 +00:00
|
|
|
|
imports = [
|
|
|
|
|
(mkRenamedOptionModule [ "services" "mingetty" ] [ "services" "getty" ])
|
2021-12-06 16:07:01 +00:00
|
|
|
|
(mkRemovedOptionModule [ "services" "getty" "serialSpeed" ] ''set non-standard baudrates with `boot.kernelParams` i.e. boot.kernelParams = ["console=ttyS2,1500000"];'')
|
2021-01-05 17:05:55 +00:00
|
|
|
|
];
|
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
options = {
|
|
|
|
|
|
2021-01-05 17:05:55 +00:00
|
|
|
|
services.getty = {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
autologinUser = mkOption {
|
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
|
Username of the account that will be automatically logged in at the console.
|
|
|
|
|
If unspecified, a login prompt is shown as usual.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2021-07-21 07:28:18 +00:00
|
|
|
|
loginProgram = mkOption {
|
|
|
|
|
type = types.path;
|
|
|
|
|
default = "${pkgs.shadow}/bin/login";
|
2021-10-06 13:57:05 +00:00
|
|
|
|
defaultText = literalExpression ''"''${pkgs.shadow}/bin/login"'';
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = ''
|
2021-07-21 07:28:18 +00:00
|
|
|
|
Path to the login binary executed by agetty.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2021-01-09 10:05:03 +00:00
|
|
|
|
loginOptions = mkOption {
|
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = ''
|
2021-01-09 10:05:03 +00:00
|
|
|
|
Template for arguments to be passed to
|
2022-08-21 13:32:41 +00:00
|
|
|
|
{manpage}`login(1)`.
|
2021-01-09 10:05:03 +00:00
|
|
|
|
|
2022-08-21 13:32:41 +00:00
|
|
|
|
See {manpage}`agetty(1)` for details,
|
2021-01-09 10:05:03 +00:00
|
|
|
|
including security considerations. If unspecified, agetty
|
2022-08-21 13:32:41 +00:00
|
|
|
|
will not be invoked with a {option}`--login-options`
|
2021-01-09 10:05:03 +00:00
|
|
|
|
option.
|
|
|
|
|
'';
|
2021-04-13 19:44:15 +00:00
|
|
|
|
example = "-h darkstar -- \\u";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extraArgs = mkOption {
|
|
|
|
|
type = types.listOf types.str;
|
|
|
|
|
default = [ ];
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = ''
|
2021-04-13 19:44:15 +00:00
|
|
|
|
Additional arguments passed to agetty.
|
|
|
|
|
'';
|
|
|
|
|
example = [ "--nohostname" ];
|
2021-01-09 10:05:03 +00:00
|
|
|
|
};
|
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
greetingLine = mkOption {
|
|
|
|
|
type = types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = ''
|
2021-01-05 17:05:55 +00:00
|
|
|
|
Welcome line printed by agetty.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
The default shows current NixOS version label, machine type and tty.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
helpLine = mkOption {
|
|
|
|
|
type = types.lines;
|
|
|
|
|
default = "";
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = ''
|
2021-01-05 17:05:55 +00:00
|
|
|
|
Help line printed by agetty below the welcome line.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
Used by the installation CD to give some hints on
|
|
|
|
|
how to proceed.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
|
|
config = {
|
|
|
|
|
# Note: this is set here rather than up there so that changing
|
|
|
|
|
# nixos.label would not rebuild manual pages
|
2021-01-05 17:05:55 +00:00
|
|
|
|
services.getty.greetingLine = mkDefault ''<<< Welcome to NixOS ${config.system.nixos.label} (\m) - \l >>>'';
|
2022-08-12 12:06:08 +00:00
|
|
|
|
services.getty.helpLine = mkIf (config.documentation.nixos.enable && config.documentation.doc.enable) "\nRun 'nixos-help' for the NixOS manual.";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
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@" =
|
|
|
|
|
{ serviceConfig.ExecStart = [
|
|
|
|
|
"" # override upstream default with an empty ExecStart
|
2021-12-06 16:07:01 +00:00
|
|
|
|
(gettyCmd "%I --keep-baud $TERM")
|
2020-04-24 23:36:52 +00:00
|
|
|
|
];
|
|
|
|
|
restartIfChanged = false;
|
|
|
|
|
};
|
|
|
|
|
|
2021-09-26 12:46:18 +00:00
|
|
|
|
systemd.services."autovt@" =
|
|
|
|
|
{ serviceConfig.ExecStart = [
|
|
|
|
|
"" # override upstream default with an empty ExecStart
|
|
|
|
|
(gettyCmd "--noclear %I $TERM")
|
|
|
|
|
];
|
|
|
|
|
restartIfChanged = false;
|
|
|
|
|
};
|
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
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;
|
|
|
|
|
};
|
|
|
|
|
|
2022-10-30 15:09:59 +00:00
|
|
|
|
environment.etc.issue = mkDefault
|
2020-04-24 23:36:52 +00:00
|
|
|
|
{ # Friendly greeting on the virtual consoles.
|
|
|
|
|
source = pkgs.writeText "issue" ''
|
|
|
|
|
|
2021-01-05 17:05:55 +00:00
|
|
|
|
[1;32m${config.services.getty.greetingLine}[0m
|
|
|
|
|
${config.services.getty.helpLine}
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|