{ ... }:
{
  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")
    '';
}
