2014-04-14 16:26:48 +02:00
|
|
|
|
{ config, lib, pkgs, ... }:
|
2009-03-06 13:27:15 +01:00
|
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
|
with lib;
|
2009-07-16 15:55:11 +02:00
|
|
|
|
|
2015-09-18 18:50:48 +02:00
|
|
|
|
let
|
2021-01-05 17:44:43 +01:00
|
|
|
|
cfg = config.services.getty;
|
2015-09-18 18:50:48 +02:00
|
|
|
|
|
2021-02-26 13:17:04 +01:00
|
|
|
|
baseArgs = [
|
2020-08-05 07:19:18 +02:00
|
|
|
|
"--login-program" "${cfg.loginProgram}"
|
2021-01-05 17:44:43 +01:00
|
|
|
|
] ++ optionals (cfg.autologinUser != null) [
|
|
|
|
|
"--autologin" cfg.autologinUser
|
|
|
|
|
] ++ optionals (cfg.loginOptions != null) [
|
|
|
|
|
"--login-options" cfg.loginOptions
|
2021-02-26 13:17:04 +01:00
|
|
|
|
] ++ cfg.extraArgs;
|
2021-01-05 17:44:43 +01:00
|
|
|
|
|
2021-02-26 13:17:04 +01:00
|
|
|
|
gettyCmd = args:
|
|
|
|
|
"@${pkgs.util-linux}/sbin/agetty agetty ${escapeShellArgs baseArgs} ${args}";
|
2015-09-18 18:50:48 +02:00
|
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
2009-07-16 15:55:11 +02:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
###### interface
|
2009-03-06 13:27:15 +01:00
|
|
|
|
|
2021-01-05 09:25:53 +01:00
|
|
|
|
imports = [
|
|
|
|
|
(mkRenamedOptionModule [ "services" "mingetty" ] [ "services" "getty" ])
|
|
|
|
|
];
|
|
|
|
|
|
2009-03-06 13:27:15 +01:00
|
|
|
|
options = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
|
2021-01-05 09:25:53 +01:00
|
|
|
|
services.getty = {
|
2009-07-16 15:55:11 +02:00
|
|
|
|
|
2015-04-12 04:14:24 +02:00
|
|
|
|
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.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2020-08-05 07:19:18 +02:00
|
|
|
|
loginProgram = mkOption {
|
|
|
|
|
type = types.path;
|
|
|
|
|
default = "${pkgs.shadow}/bin/login";
|
|
|
|
|
description = ''
|
|
|
|
|
Path to the login binary executed by agetty.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2021-01-05 17:44:43 +01:00
|
|
|
|
loginOptions = mkOption {
|
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
default = null;
|
|
|
|
|
description = ''
|
|
|
|
|
Template for arguments to be passed to
|
|
|
|
|
<citerefentry><refentrytitle>login</refentrytitle>
|
|
|
|
|
<manvolnum>1</manvolnum></citerefentry>.
|
|
|
|
|
|
|
|
|
|
See <citerefentry><refentrytitle>agetty</refentrytitle>
|
|
|
|
|
<manvolnum>1</manvolnum></citerefentry> for details,
|
|
|
|
|
including security considerations. If unspecified, agetty
|
|
|
|
|
will not be invoked with a <option>--login-options</option>
|
|
|
|
|
option.
|
|
|
|
|
'';
|
2021-02-26 13:17:04 +01:00
|
|
|
|
example = "-h darkstar -- \\u";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extraArgs = mkOption {
|
|
|
|
|
type = types.listOf types.str;
|
|
|
|
|
default = [ ];
|
|
|
|
|
description = ''
|
|
|
|
|
Additional arguments passed to agetty.
|
|
|
|
|
'';
|
|
|
|
|
example = [ "--nohostname" ];
|
2021-01-05 17:44:43 +01:00
|
|
|
|
};
|
|
|
|
|
|
2009-07-16 15:55:11 +02:00
|
|
|
|
greetingLine = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
|
type = types.str;
|
2009-07-16 15:55:11 +02:00
|
|
|
|
description = ''
|
2021-01-05 09:25:53 +01:00
|
|
|
|
Welcome line printed by agetty.
|
2015-09-18 18:50:48 +02:00
|
|
|
|
The default shows current NixOS version label, machine type and tty.
|
2009-07-16 15:55:11 +02:00
|
|
|
|
'';
|
|
|
|
|
};
|
2009-03-06 13:27:15 +01:00
|
|
|
|
|
2009-07-16 15:55:11 +02:00
|
|
|
|
helpLine = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
|
type = types.lines;
|
2009-07-16 15:55:11 +02:00
|
|
|
|
default = "";
|
|
|
|
|
description = ''
|
2021-01-05 09:25:53 +01:00
|
|
|
|
Help line printed by agetty below the welcome line.
|
2009-07-16 15:55:11 +02:00
|
|
|
|
Used by the installation CD to give some hints on
|
|
|
|
|
how to proceed.
|
|
|
|
|
'';
|
2009-03-06 13:27:15 +01:00
|
|
|
|
};
|
2009-07-16 15:55:11 +02:00
|
|
|
|
|
2014-02-03 23:20:41 +01:00
|
|
|
|
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.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2009-03-06 13:27:15 +01:00
|
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
|
2009-03-06 13:27:15 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2009-07-16 15:55:11 +02:00
|
|
|
|
###### implementation
|
|
|
|
|
|
2015-09-18 18:50:48 +02:00
|
|
|
|
config = {
|
|
|
|
|
# Note: this is set here rather than up there so that changing
|
2017-04-01 02:00:00 +02:00
|
|
|
|
# nixos.label would not rebuild manual pages
|
2021-01-05 09:25:53 +01:00
|
|
|
|
services.getty.greetingLine = mkDefault ''<<< Welcome to NixOS ${config.system.nixos.label} (\m) - \l >>>'';
|
2015-09-18 18:50:48 +02:00
|
|
|
|
|
2014-03-12 18:29:06 +01:00
|
|
|
|
systemd.services."getty@" =
|
2017-07-16 19:28:02 +02:00
|
|
|
|
{ serviceConfig.ExecStart = [
|
|
|
|
|
"" # override upstream default with an empty ExecStart
|
|
|
|
|
(gettyCmd "--noclear --keep-baud %I 115200,38400,9600 $TERM")
|
|
|
|
|
];
|
2014-03-12 18:29:06 +01:00
|
|
|
|
restartIfChanged = false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
systemd.services."serial-getty@" =
|
2021-01-05 09:25:53 +01:00
|
|
|
|
let speeds = concatStringsSep "," (map toString config.services.getty.serialSpeed); in
|
2017-07-16 19:28:02 +02:00
|
|
|
|
{ serviceConfig.ExecStart = [
|
|
|
|
|
"" # override upstream default with an empty ExecStart
|
2021-06-25 09:50:52 +02:00
|
|
|
|
(gettyCmd "%I --keep-baud ${speeds} $TERM")
|
2017-07-16 19:28:02 +02:00
|
|
|
|
];
|
2014-04-16 16:10:11 +02:00
|
|
|
|
restartIfChanged = false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
systemd.services."container-getty@" =
|
2017-08-13 19:07:38 +02:00
|
|
|
|
{ serviceConfig.ExecStart = [
|
|
|
|
|
"" # override upstream default with an empty ExecStart
|
|
|
|
|
(gettyCmd "--noclear --keep-baud pts/%I 115200,38400,9600 $TERM")
|
|
|
|
|
];
|
2014-03-12 18:29:06 +01:00
|
|
|
|
restartIfChanged = false;
|
|
|
|
|
};
|
2012-07-20 17:36:09 +02:00
|
|
|
|
|
2019-08-13 23:52:01 +02:00
|
|
|
|
systemd.services.console-getty =
|
2017-08-13 19:07:38 +02:00
|
|
|
|
{ serviceConfig.ExecStart = [
|
|
|
|
|
"" # override upstream default with an empty ExecStart
|
|
|
|
|
(gettyCmd "--noclear --keep-baud console 115200,38400,9600 $TERM")
|
|
|
|
|
];
|
2014-08-25 02:45:11 +02:00
|
|
|
|
serviceConfig.Restart = "always";
|
|
|
|
|
restartIfChanged = false;
|
2015-09-18 18:50:48 +02:00
|
|
|
|
enable = mkDefault config.boot.isContainer;
|
2014-08-25 02:45:11 +02:00
|
|
|
|
};
|
|
|
|
|
|
2019-09-14 19:51:29 +02:00
|
|
|
|
environment.etc.issue =
|
2009-07-16 15:55:11 +02:00
|
|
|
|
{ # Friendly greeting on the virtual consoles.
|
2012-08-06 21:53:04 +02:00
|
|
|
|
source = pkgs.writeText "issue" ''
|
|
|
|
|
|
2021-01-05 09:25:53 +01:00
|
|
|
|
[1;32m${config.services.getty.greetingLine}[0m
|
|
|
|
|
${config.services.getty.helpLine}
|
2012-08-06 21:53:04 +02:00
|
|
|
|
|
|
|
|
|
'';
|
2009-07-16 15:55:11 +02:00
|
|
|
|
};
|
2012-06-18 23:58:31 +02:00
|
|
|
|
|
2009-07-16 15:55:11 +02:00
|
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
|
2006-11-19 21:07:45 +01:00
|
|
|
|
}
|