nixpkgs/nixos/modules/services/ttys/agetty.nix

90 lines
2.6 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
with lib;
{
###### interface
options = {
services.mingetty = {
greetingLine = mkOption {
2013-10-30 17:37:45 +01:00
type = types.str;
default = ''<<< Welcome to NixOS ${config.system.nixosVersion} (\m) - \l >>>'';
description = ''
Welcome line printed by mingetty.
'';
};
helpLine = mkOption {
2013-10-30 17:37:45 +01:00
type = types.lines;
default = "";
description = ''
2012-06-18 23:58:31 +02:00
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 = {
systemd.services."getty@" =
{ serviceConfig.ExecStart = "@${pkgs.utillinux}/sbin/agetty agetty --noclear --login-program ${pkgs.shadow}/bin/login --keep-baud %I 115200,38400,9600 $TERM";
restartIfChanged = false;
};
systemd.services."serial-getty@" =
{ serviceConfig.ExecStart =
let speeds = concatStringsSep "," (map toString config.services.mingetty.serialSpeed);
in "@${pkgs.utillinux}/sbin/agetty agetty --login-program ${pkgs.shadow}/bin/login %I ${speeds} $TERM";
restartIfChanged = false;
};
systemd.services."container-getty@" =
{ unitConfig.ConditionPathExists = "/dev/pts/%I"; # Work around being respawned when "machinectl login" exits.
serviceConfig.ExecStart = "@${pkgs.utillinux}/sbin/agetty agetty --noclear --login-program ${pkgs.shadow}/bin/login --keep-baud pts/%I 115200,38400,9600 $TERM";
restartIfChanged = false;
};
2012-07-20 17:36:09 +02:00
systemd.services."console-getty" =
{ serviceConfig.ExecStart = "@${pkgs.utillinux}/sbin/agetty agetty --noclear --login-program ${pkgs.shadow}/bin/login --keep-baud console 115200,38400,9600 $TERM";
serviceConfig.Restart = "always";
restartIfChanged = false;
enable = mkDefault config.boot.isContainer;
};
environment.etc = singleton
{ # Friendly greeting on the virtual consoles.
2012-08-06 21:53:04 +02:00
source = pkgs.writeText "issue" ''
${config.services.mingetty.greetingLine}
${config.services.mingetty.helpLine}
'';
target = "issue";
};
2012-06-18 23:58:31 +02:00
};
}