summaryrefslogtreecommitdiffstats
path: root/nixos/tests/stardust-xr/flatland.nix
blob: 748a1e0cbd8452b911c3d25d0b553ea04a5a7bd9 (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
51
52
53
54
55
56
57
{ ... }:
{
  name = "stardust-xr-flatland";

  # Doesn't understand @polling_condition
  skipTypeCheck = true;

  nodes.machine =
    {
      lib,
      pkgs,
      config,
      ...
    }:

    {
      imports = [ ./common.nix ];

      systemd.user.services.stardust-xr-flatland = {
        wantedBy = [ "xdg-desktop-autostart.target" ];
        requires = [ "stardust-xr-server.service" ];
        after = [ "stardust-xr-server.service" ];
        script = lib.getExe pkgs.stardust-xr-flatland;
        environment.RUST_BACKTRACE = "full";
      };

      systemd.user.services.test-wayland-app = {
        wantedBy = [ "xdg-desktop-autostart.target" ];
        requires = [ "stardust-xr-flatland.service" ];
        after = [ "stardust-xr-flatland.service" ];
        script = lib.getExe pkgs.wayland-colorbar;
        environment = {
          DISPLAY = "";
          WAYLAND_DISPLAY = "wayland-0";
        };
      };
    };

  testScript =
    { nodes, ... }:
    ''
      @polling_condition()
      def wayland_client_running():
        machine.wait_for_unit("test-wayland-app.service", "alice")

      with subtest("Ensure X11 starts"):
        start_all()
        machine.succeed("loginctl enable-linger alice")
        machine.wait_for_x()

      with subtest("Ensure system works"):
        with wayland_client_running:
          # TODO: 20 seconds should be long enough for anything, but this is theoretically flaky
          machine.sleep(20)
          machine.screenshot("screen")
    '';
}