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