1import ./make-test-python.nix ({ pkgs, lib, ... }: {
2 name = "miriway";
3
4 meta = {
5 maintainers = with lib.maintainers; [ OPNA2608 ];
6 # Natively running Mir has problems with capturing the first registered libinput device.
7 # In our VM runners on ARM and on some hardware configs (my RPi4, distro-independent), this misses the keyboard.
8 # It can be worked around by dis- and reconnecting the affected hardware, but we can't do this in these tests.
9 # https://github.com/MirServer/mir/issues/2837
10 broken = pkgs.stdenv.hostPlatform.isAarch;
11 };
12
13 nodes.machine = { config, ... }: {
14 imports = [
15 ./common/auto.nix
16 ./common/user-account.nix
17 ];
18
19 # Seems to very rarely get interrupted by oom-killer
20 virtualisation.memorySize = 2047;
21
22 test-support.displayManager.auto = {
23 enable = true;
24 user = "alice";
25 };
26
27 services.xserver = {
28 enable = true;
29 displayManager.defaultSession = lib.mkForce "miriway";
30 };
31
32 programs.miriway = {
33 enable = true;
34 config = ''
35 add-wayland-extensions=all
36 enable-x11=
37
38 ctrl-alt=t:foot --maximized
39 ctrl-alt=a:env WINIT_UNIX_BACKEND=x11 WAYLAND_DISPLAY=invalid alacritty --option window.startup_mode=maximized
40
41 shell-component=dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY
42
43 shell-component=foot --maximized
44 '';
45 };
46
47 environment = {
48 shellAliases = {
49 test-wayland = "wayland-info | tee /tmp/test-wayland.out && touch /tmp/test-wayland-exit-ok";
50 test-x11 = "glinfo | tee /tmp/test-x11.out && touch /tmp/test-x11-exit-ok";
51 };
52
53 systemPackages = with pkgs; [
54 mesa-demos
55 wayland-utils
56 foot
57 alacritty
58 ];
59
60 # To help with OCR
61 etc."xdg/foot/foot.ini".text = lib.generators.toINI { } {
62 main = {
63 font = "inconsolata:size=16";
64 };
65 colors = rec {
66 foreground = "000000";
67 background = "ffffff";
68 regular2 = foreground;
69 };
70 };
71 etc."xdg/alacritty/alacritty.yml".text = lib.generators.toYAML { } {
72 font = rec {
73 normal.family = "Inconsolata";
74 bold.family = normal.family;
75 italic.family = normal.family;
76 bold_italic.family = normal.family;
77 size = 16;
78 };
79 colors = rec {
80 primary = {
81 foreground = "0x000000";
82 background = "0xffffff";
83 };
84 normal = {
85 green = primary.foreground;
86 };
87 };
88 };
89 };
90
91 fonts.fonts = [ pkgs.inconsolata ];
92 };
93
94 enableOCR = true;
95
96 testScript = { nodes, ... }: ''
97 start_all()
98 machine.wait_for_unit("multi-user.target")
99
100 # Wait for Miriway to complete startup
101 machine.wait_for_file("/run/user/1000/wayland-0")
102 machine.succeed("pgrep miriway-shell")
103 machine.screenshot("miriway_launched")
104
105 # Test Wayland
106 # We let Miriway start the first terminal, as we might get stuck if it's not ready to process the first keybind
107 # machine.send_key("ctrl-alt-t")
108 machine.wait_for_text("alice@machine")
109 machine.send_chars("test-wayland\n")
110 machine.wait_for_file("/tmp/test-wayland-exit-ok")
111 machine.copy_from_vm("/tmp/test-wayland.out")
112 machine.screenshot("foot_wayland_info")
113 # Only succeeds when a mouse is moved inside an interactive session?
114 # machine.send_chars("exit\n")
115 # machine.wait_until_fails("pgrep foot")
116 machine.succeed("pkill foot")
117
118 # Test XWayland
119 machine.send_key("ctrl-alt-a")
120 machine.wait_for_text("alice@machine")
121 machine.send_chars("test-x11\n")
122 machine.wait_for_file("/tmp/test-x11-exit-ok")
123 machine.copy_from_vm("/tmp/test-x11.out")
124 machine.screenshot("alacritty_glinfo")
125 # Only succeeds when a mouse is moved inside an interactive session?
126 # machine.send_chars("exit\n")
127 # machine.wait_until_fails("pgrep alacritty")
128 machine.succeed("pkill alacritty")
129 '';
130})