mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-19 12:14:10 +00:00
2f671ccc7a
Since the update to wlroots 0.13 (e03dde82a7
) the default VGA card isn't supported anymore and we needed to switch to virtio (qxl didn't work either). However, as it turned out "-vga virtio" (28b8cff301
) broke the test on AArch64. Luckily there's a third option that works on all three supported platforms: virtio-gpu-pci According to [0] "This device lacks VGA compatibility mode but is otherwise identical to the virtio vga device. UEFI firmware can handle this, and if your guests has drivers too you can use this instead of virtio-vga. This will reduce the attack surface (no complex VGA emulation support) and reduce the memory footprint by 8 MB (no pci memory bar for VGA compatibility). This device can be placed in a PCI Express slot." So in the end this seems like the ideal choice :) See also [1]. [0]: https://www.kraxel.org/blog/2019/09/display-devices-in-qemu/#virtio-gpu-pci [1]: https://patches.openembedded.org/patch/164351/
107 lines
3.5 KiB
Nix
107 lines
3.5 KiB
Nix
import ./make-test-python.nix ({ pkgs, lib, ...} :
|
|
|
|
{
|
|
name = "sway";
|
|
meta = {
|
|
maintainers = with lib.maintainers; [ primeos synthetica ];
|
|
};
|
|
|
|
machine = { config, ... }: {
|
|
# Automatically login on tty1 as a normal user:
|
|
imports = [ ./common/user-account.nix ];
|
|
services.getty.autologinUser = "alice";
|
|
|
|
environment = {
|
|
# For glinfo and wayland-info:
|
|
systemPackages = with pkgs; [ mesa-demos wayland-utils ];
|
|
# Use a fixed SWAYSOCK path (for swaymsg):
|
|
variables."SWAYSOCK" = "/tmp/sway-ipc.sock";
|
|
# For convenience:
|
|
shellAliases = {
|
|
test-x11 = "glinfo | head -n 3 | tee /tmp/test-x11.out && touch /tmp/test-x11-exit-ok";
|
|
test-wayland = "wayland-info | tee /tmp/test-wayland.out && touch /tmp/test-wayland-exit-ok";
|
|
};
|
|
};
|
|
|
|
# Automatically configure and start Sway when logging in on tty1:
|
|
programs.bash.loginShellInit = ''
|
|
if [ "$(tty)" = "/dev/tty1" ]; then
|
|
set -e
|
|
|
|
mkdir -p ~/.config/sway
|
|
sed s/Mod4/Mod1/ /etc/sway/config > ~/.config/sway/config
|
|
|
|
sway --validate
|
|
sway && touch /tmp/sway-exit-ok
|
|
fi
|
|
'';
|
|
|
|
programs.sway.enable = true;
|
|
|
|
# To test pinentry via gpg-agent:
|
|
programs.gnupg.agent.enable = true;
|
|
|
|
virtualisation.memorySize = 1024;
|
|
# Need to switch to a different GPU driver than the default one (-vga std) so that Sway can launch:
|
|
virtualisation.qemu.options = [ "-vga none -device virtio-gpu-pci" ];
|
|
};
|
|
|
|
enableOCR = true;
|
|
|
|
testScript = { nodes, ... }: ''
|
|
start_all()
|
|
machine.wait_for_unit("multi-user.target")
|
|
|
|
# To check the version:
|
|
print(machine.succeed("sway --version"))
|
|
|
|
# Wait for Sway to complete startup:
|
|
machine.wait_for_file("/run/user/1000/wayland-1")
|
|
machine.wait_for_file("/tmp/sway-ipc.sock")
|
|
|
|
# Test XWayland:
|
|
machine.succeed(
|
|
"su - alice -c 'swaymsg exec WINIT_UNIX_BACKEND=x11 WAYLAND_DISPLAY=invalid alacritty'"
|
|
)
|
|
machine.wait_for_text("alice@machine")
|
|
machine.send_chars("test-x11\n")
|
|
machine.wait_for_file("/tmp/test-x11-exit-ok")
|
|
print(machine.succeed("cat /tmp/test-x11.out"))
|
|
machine.screenshot("alacritty_glinfo")
|
|
machine.succeed("pkill alacritty")
|
|
|
|
# Start a terminal (Alacritty) on workspace 3:
|
|
machine.send_key("alt-3")
|
|
machine.succeed(
|
|
"su - alice -c 'swaymsg exec WINIT_UNIX_BACKEND=wayland DISPLAY=invalid alacritty'"
|
|
)
|
|
machine.wait_for_text("alice@machine")
|
|
machine.send_chars("test-wayland\n")
|
|
machine.wait_for_file("/tmp/test-wayland-exit-ok")
|
|
print(machine.succeed("cat /tmp/test-wayland.out"))
|
|
machine.screenshot("alacritty_wayland_info")
|
|
machine.send_key("alt-shift-q")
|
|
machine.wait_until_fails("pgrep alacritty")
|
|
|
|
# Test gpg-agent starting pinentry-gnome3 via D-Bus (tests if
|
|
# $WAYLAND_DISPLAY is correctly imported into the D-Bus user env):
|
|
machine.succeed(
|
|
"su - alice -c 'swaymsg -- exec gpg --no-tty --yes --quick-generate-key test'"
|
|
)
|
|
machine.wait_until_succeeds("pgrep --exact gpg")
|
|
machine.wait_for_text("Passphrase")
|
|
machine.screenshot("gpg_pinentry")
|
|
machine.send_key("alt-shift-q")
|
|
machine.wait_until_fails("pgrep --exact gpg")
|
|
|
|
# Test swaynag:
|
|
machine.send_key("alt-shift-e")
|
|
machine.wait_for_text("You pressed the exit shortcut.")
|
|
machine.screenshot("sway_exit")
|
|
|
|
# Exit Sway and verify process exit status 0:
|
|
machine.succeed("su - alice -c 'swaymsg exit || true'")
|
|
machine.wait_for_file("/tmp/sway-exit-ok")
|
|
'';
|
|
})
|