summaryrefslogtreecommitdiffstats
path: root/nixos/tests/logkeys.nix
blob: eeb4c27ee2b0fd728e5cb178aa409eb3827313e6 (plain)
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
{ lib, ... }:
{
  name = "logkeys";
  meta.maintainers = with lib.maintainers; [ h7x4 ];

  nodes.machine =
    { pkgs, ... }:
    {
      imports = [ ./common/user-account.nix ];

      services.getty.autologinUser = "alice";

      services.logkeys = {
        enable = true;
        device = "virtio-kbd";
      };

      # logkeys doesn't support specifying a device in `by-path`.
      # In order not to make the test dependend on the ordering of the input event devices,
      # we'll create a custom symlink before starting the service.
      systemd.services.logkeys.serviceConfig.ExecStartPre = [
        "+${lib.getExe' pkgs.coreutils "ln"} -s /dev/input/by-path/pci-0000:00:0a.0-event-kbd /dev/input/virtio-kbd"
      ];
    };

  testScript = ''
    machine.wait_for_unit("getty@tty1.service")
    machine.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
    machine.wait_for_unit("logkeys.service")

    machine.send_chars("hello world\n")
    machine.wait_until_succeeds("grep 'hello world' /var/log/logkeys.log")
  '';
}