summary refs log tree commit diff
path: root/nixos/modules/tasks/kbd.nix
blob: e36e9f85f1e3b89b8081d377caaa130466b3d472 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{ config, lib, pkgs, ... }:

with lib;

let

  makeColor = n: value: "COLOR_${toString n}=${value}";

  vconsoleConf = pkgs.writeText "vconsole.conf"
    ''
      KEYMAP=${config.i18n.consoleKeyMap}
      FONT=${config.i18n.consoleFont}
    '' + concatImapStringsSep "\n" makeColor config.i18n.consoleColors;

in

{
  ###### interface

  options = {

    # most options are defined in i18n.nix

    # FIXME: still needed?
    boot.extraTTYs = mkOption {
      default = [];
      type = types.listOf types.str;
      example = ["tty8" "tty9"];
      description = ''
        Tty (virtual console) devices, in addition to the consoles on
        which mingetty and syslogd run, that must be initialised.
        Only useful if you have some program that you want to run on
        some fixed console.  For example, the NixOS installation CD
        opens the manual in a web browser on console 7, so it sets
        <option>boot.extraTTYs</option> to <literal>["tty7"]</literal>.
      '';
    };

  };


  ###### implementation

  config = {

    environment.systemPackages = [ pkgs.kbd ];

    # Let systemd-vconsole-setup.service do the work of setting up the
    # virtual consoles.  FIXME: trigger a restart of
    # systemd-vconsole-setup.service if /etc/vconsole.conf changes.
    environment.etc."vconsole.conf".source = vconsoleConf;

    # This is identical to the systemd-vconsole-setup.service unit
    # shipped with systemd, except that it uses /dev/tty1 instead of
    # /dev/tty0 to prevent putting the X server in non-raw mode, and
    # it has a restart trigger.
    systemd.services."systemd-vconsole-setup" =
      { wantedBy = [ "multi-user.target" ];
        before = [ "display-manager.service" ];
        after = [ "systemd-udev-settle.service" ];
        restartTriggers = [ vconsoleConf ];
      };

  };

}