vuls: init at 0.27.0 (#348530)
[NixPkgs.git] / nixos / tests / miracle-wm.nix
blob2bb62222b22a149e4d076837fb402688ebe435cd
1 { pkgs, lib, ... }:
3   name = "miracle-wm";
5   meta = {
6     maintainers = with lib.maintainers; [ OPNA2608 ];
7   };
9   nodes.machine =
10     { config, ... }:
11     {
12       imports = [
13         ./common/auto.nix
14         ./common/user-account.nix
15       ];
17       # Seems to very rarely get interrupted by oom-killer
18       virtualisation.memorySize = 2047;
20       test-support.displayManager.auto = {
21         enable = true;
22         user = "alice";
23       };
25       services.xserver.enable = true;
26       services.displayManager.defaultSession = lib.mkForce "miracle-wm";
28       programs.wayland.miracle-wm.enable = true;
30       # To ensure a specific config for the tests
31       systemd.tmpfiles.rules =
32         let
33           testConfig = (pkgs.formats.yaml { }).generate "miracle-wm.yaml" {
34             terminal = "env WINIT_UNIX_BACKEND=x11 WAYLAND_DISPLAY= alacritty";
35             startup_apps = [
36               {
37                 command = "foot";
38                 restart_on_death = false;
39               }
40             ];
41           };
42         in
43         [
44           "d ${config.users.users.alice.home}/.config 0700 alice users - -"
45           "L ${config.users.users.alice.home}/.config/miracle-wm.yaml - - - - ${testConfig}"
46         ];
48       environment = {
49         shellAliases = {
50           test-wayland = "wayland-info | tee /tmp/test-wayland.out && touch /tmp/test-wayland-exit-ok";
51           test-x11 = "glinfo | tee /tmp/test-x11.out && touch /tmp/test-x11-exit-ok";
52         };
54         systemPackages = with pkgs; [
55           mesa-demos
56           wayland-utils
57           foot
58           alacritty
59         ];
61         # To help with OCR
62         etc."xdg/foot/foot.ini".text = lib.generators.toINI { } {
63           main = {
64             font = "inconsolata:size=16";
65           };
66           colors = rec {
67             foreground = "000000";
68             background = "ffffff";
69             regular2 = foreground;
70           };
71         };
72         etc."xdg/alacritty/alacritty.yml".text = lib.generators.toYAML { } {
73           font = rec {
74             normal.family = "Inconsolata";
75             bold.family = normal.family;
76             italic.family = normal.family;
77             bold_italic.family = normal.family;
78             size = 16;
79           };
80           colors = rec {
81             primary = {
82               foreground = "0x000000";
83               background = "0xffffff";
84             };
85             normal = {
86               green = primary.foreground;
87             };
88           };
89         };
90       };
92       fonts.packages = [ pkgs.inconsolata ];
93     };
95   enableOCR = true;
97   testScript =
98     { ... }:
99     ''
100       start_all()
101       machine.wait_for_unit("multi-user.target")
103       # Wait for Miriway to complete startup
104       machine.wait_for_file("/run/user/1000/wayland-0")
105       machine.succeed("pgrep miracle-wm")
106       machine.screenshot("miracle-wm_launched")
108       # Test Wayland
109       with subtest("wayland client works"):
110           # We let miracle-wm start the first terminal, as we might get stuck if it's not ready to process the first keybind
111           # machine.send_key("ctrl-alt-t")
112           machine.wait_for_text("alice@machine")
113           machine.send_chars("test-wayland\n")
114           machine.wait_for_file("/tmp/test-wayland-exit-ok")
115           machine.copy_from_vm("/tmp/test-wayland.out")
116           machine.screenshot("foot_wayland_info")
117           machine.send_chars("exit\n")
118           machine.wait_until_fails("pgrep foot")
120       # Test XWayland
121       with subtest("x11 client works"):
122           machine.send_key("meta_l-ret")
123           machine.wait_for_text("alice@machine")
124           machine.send_chars("test-x11\n")
125           machine.wait_for_file("/tmp/test-x11-exit-ok")
126           machine.copy_from_vm("/tmp/test-x11.out")
127           machine.screenshot("alacritty_glinfo")
128           machine.send_chars("exit\n")
129           machine.wait_until_fails("pgrep alacritty")
130     '';