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