1import ./make-test-python.nix (
2 { pkgs, lib, ... }:
3
4 {
5 name = "tinywl";
6 meta = {
7 maintainers = with lib.maintainers; [ primeos ];
8 };
9
10 nodes.machine =
11 { config, ... }:
12 {
13 # Automatically login on tty1 as a normal user:
14 imports = [ ./common/user-account.nix ];
15 services.getty.autologinUser = "alice";
16 security.polkit.enable = true;
17
18 environment = {
19 systemPackages = with pkgs; [
20 tinywl
21 foot
22 wayland-utils
23 ];
24 };
25
26 hardware.graphics.enable = true;
27
28 # Automatically start TinyWL when logging in on tty1:
29 programs.bash.loginShellInit = ''
30 if [ "$(tty)" = "/dev/tty1" ]; then
31 set -e
32 test ! -e /tmp/tinywl.log # Only start tinywl once
33 readonly TEST_CMD="wayland-info |& tee /tmp/test-wayland.out && touch /tmp/test-wayland-exit-ok; read"
34 readonly FOOT_CMD="foot sh -c '$TEST_CMD'"
35 tinywl -s "$FOOT_CMD" |& tee /tmp/tinywl.log
36 touch /tmp/tinywl-exit-ok
37 fi
38 '';
39
40 # Switch to a different GPU driver (default: -vga std), otherwise TinyWL segfaults:
41 virtualisation.qemu.options = [ "-vga none -device virtio-gpu-pci" ];
42 };
43
44 testScript =
45 { nodes, ... }:
46 ''
47 start_all()
48 machine.wait_for_unit("multi-user.target")
49
50 # Wait for complete startup:
51 machine.wait_until_succeeds("pgrep tinywl")
52 machine.wait_for_file("/run/user/1000/wayland-0")
53 machine.wait_until_succeeds("pgrep foot")
54 machine.wait_for_file("/tmp/test-wayland-exit-ok")
55
56 # Make a screenshot and save the result:
57 machine.screenshot("tinywl_foot")
58 print(machine.succeed("cat /tmp/test-wayland.out"))
59 machine.copy_from_vm("/tmp/test-wayland.out")
60
61 # Terminate cleanly:
62 machine.send_key("alt-esc")
63 machine.wait_until_fails("pgrep foot")
64 machine.wait_until_fails("pgrep tinywl")
65 machine.wait_for_file("/tmp/tinywl-exit-ok")
66 machine.copy_from_vm("/tmp/tinywl.log")
67 '';
68 }
69)