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