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