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

85 lines
2.2 KiB
Nix
Raw Normal View History

{ config, pkgs, ... }:
with pkgs.lib;
{
###### interface
options = {
services.mingetty = {
greetingLine = mkOption {
2013-10-30 16:37:45 +00:00
type = types.str;
default = ''<<< Welcome to NixOS ${config.system.nixosVersion} (\m) - \l >>>'';
description = ''
Welcome line printed by mingetty.
'';
};
helpLine = mkOption {
2013-10-30 16:37:45 +00:00
type = types.lines;
default = "";
description = ''
2012-06-18 21:58:31 +00: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@" =
{ baseUnit = pkgs.runCommand "getty.service" {}
''
sed '/ExecStart/ d' < ${config.systemd.package}/example/systemd/system/getty@.service > $out
'';
serviceConfig.ExecStart = "@${pkgs.utillinux}/sbin/agetty agetty --noclear --login-program ${pkgs.shadow}/bin/login %I 38400";
restartIfChanged = false;
};
systemd.services."serial-getty@" =
{ baseUnit = pkgs.runCommand "serial-getty.service" {}
''
sed '/ExecStart/ d' < ${config.systemd.package}/example/systemd/system/serial-getty@.service > $out
'';
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}";
restartIfChanged = false;
};
2012-07-20 15:36:09 +00:00
environment.etc = singleton
{ # Friendly greeting on the virtual consoles.
2012-08-06 19:53:04 +00:00
source = pkgs.writeText "issue" ''
${config.services.mingetty.greetingLine}
${config.services.mingetty.helpLine}
'';
target = "issue";
};
2012-06-18 21:58:31 +00:00
};
}