summaryrefslogtreecommitdiffstats
path: root/nixos/tests/kmscon.nix
blob: 130db8f0bc4a6453a26ef70cca403c8a749d2faf (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{ ... }:
{
  name = "kmscon";

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

      services.getty.autologinUser = "alice";

      hardware.graphics.enable = true;

      fonts = {
        fontconfig.enable = true;
        packages = [ pkgs.nerd-fonts.jetbrains-mono ];
      };

      services.kmscon = {
        enable = true;
        package = pkgs.kmscon;
        config = {
          font-name = "JetBrainsMono Nerd Font";
          hwaccel = true;
          term = "kmscon";
        };
      };
    };

  enableOCR = true;

  testScript = ''
    machine.wait_for_unit("default.target")

    with subtest("ensure we can open a tty"):
      machine.wait_for_text("alice@machine")

      machine.send_chars("echo $TERM | tee /tmp/term.txt\n")
      machine.wait_until_succeeds("test -s /tmp/term.txt")
      term = machine.succeed("cat /tmp/term.txt").strip()
      assert term == "kmscon", f"Unexpected TERM value: {term!r}"

      machine.screenshot("tty.png")
  '';
}