summaryrefslogtreecommitdiffstats
path: root/nixos/tests/cage.nix
blob: fa0c8125862d4bcbda455ff8142694a464b4412e (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
{ pkgs, ... }:

{
  name = "cage";
  meta = {
    maintainers = [ ];
  };

  nodes.machine =
    { ... }:

    {
      imports = [ ./common/user-account.nix ];

      fonts.packages = with pkgs; [ dejavu_fonts ];

      services.cage = {
        enable = true;
        user = "alice";
        program = "${pkgs.xterm}/bin/xterm";
      };

      # Need to switch to a different GPU driver than the default one (-vga std) so that Cage can launch:
      virtualisation.qemu.options = [ "-vga none -device virtio-gpu-pci" ];
    };

  enableOCR = true;

  testScript =
    { nodes, ... }:
    let
      user = nodes.machine.users.users.alice;
    in
    ''
      with subtest("Wait for cage to boot up"):
          start_all()
          machine.wait_for_file("/run/user/${toString user.uid}/wayland-0.lock")
          machine.wait_until_succeeds("pgrep xterm")
          machine.wait_for_text("alice@machine")
          machine.screenshot("screen")
    '';
}