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