2022-06-05 01:05:28 +00:00
|
|
|
{ pkgs, lib, ... }:
|
2022-06-04 21:45:06 +00:00
|
|
|
{
|
|
|
|
name = "firstTest";
|
|
|
|
|
|
|
|
nodes.test-machine = { suites ? null, ... }: {
|
|
|
|
imports = suites.iso;
|
|
|
|
|
2022-06-05 01:05:28 +00:00
|
|
|
home-manager.users.pub-solar.programs.zsh.shellAliases = {
|
|
|
|
test-x11 = "glinfo | 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";
|
|
|
|
};
|
|
|
|
|
|
|
|
# source: https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/tests/sway.nix
|
2022-06-04 21:45:06 +00:00
|
|
|
environment = {
|
2022-06-05 01:05:28 +00:00
|
|
|
# For glinfo and wayland-info:
|
|
|
|
systemPackages = with pkgs; [ mesa-demos wayland-utils alacritty ];
|
|
|
|
# Use a fixed SWAYSOCK path (for swaymsg):
|
2022-06-04 21:45:06 +00:00
|
|
|
variables = {
|
|
|
|
"SWAYSOCK" = "/tmp/sway-ipc.sock";
|
|
|
|
# TODO: Investigate if we can get hardware acceleration to work (via
|
|
|
|
# virtio-gpu and Virgil). We currently have to use the Pixman software
|
|
|
|
# renderer since the GLES2 renderer doesn't work inside the VM (even
|
|
|
|
# with WLR_RENDERER_ALLOW_SOFTWARE):
|
|
|
|
# "WLR_RENDERER_ALLOW_SOFTWARE" = "1";
|
|
|
|
"WLR_RENDERER" = "pixman";
|
|
|
|
};
|
|
|
|
|
2022-06-05 01:05:28 +00:00
|
|
|
# To help with OCR:
|
|
|
|
etc."xdg/foot/foot.ini".text = lib.generators.toINI { } {
|
|
|
|
main = {
|
|
|
|
font = "inconsolata:size=14";
|
|
|
|
};
|
|
|
|
colors = rec {
|
|
|
|
foreground = "000000";
|
|
|
|
background = "ffffff";
|
|
|
|
regular2 = foreground;
|
|
|
|
};
|
2022-06-04 21:45:06 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-06-05 01:05:28 +00:00
|
|
|
fonts.fonts = [ pkgs.inconsolata ];
|
|
|
|
|
2022-06-04 21:45:06 +00:00
|
|
|
# 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" ];
|
2022-06-05 01:05:28 +00:00
|
|
|
virtualisation.cores = 4;
|
|
|
|
virtualisation.memorySize = 2048;
|
2022-06-04 21:45:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enableOCR = true;
|
|
|
|
|
|
|
|
testScript = ''
|
2022-06-05 01:05:28 +00:00
|
|
|
import shlex
|
|
|
|
def swaymsg(command: str, succeed=True):
|
|
|
|
with machine.nested(f"sending swaymsg {command!r}" + " (allowed to fail)" * (not succeed)):
|
|
|
|
(machine.succeed if succeed else machine.execute)(
|
|
|
|
f"su - pub-solar -c {shlex.quote('swaymsg -- ' + command)}"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-06-04 21:45:06 +00:00
|
|
|
machine.wait_for_unit("multi-user.target")
|
2022-06-05 01:05:28 +00:00
|
|
|
|
2022-06-04 21:45:06 +00:00
|
|
|
# To check the version:
|
|
|
|
print(machine.succeed("sway --version"))
|
2022-06-05 01:05:28 +00:00
|
|
|
|
2022-06-04 21:45:06 +00:00
|
|
|
# Wait for Sway to complete startup:
|
|
|
|
machine.wait_for_file("/run/user/1000/wayland-1")
|
|
|
|
machine.wait_for_file("/tmp/sway-ipc.sock")
|
2022-06-05 01:05:28 +00:00
|
|
|
machine.wait_for_file("/run/user/1000/pipewire-0")
|
2022-06-04 21:45:06 +00:00
|
|
|
|
2022-06-05 01:05:28 +00:00
|
|
|
# Start a terminal (foot) on workspace 3:
|
|
|
|
machine.wait_for_text("1")
|
|
|
|
machine.send_key("meta_l-3")
|
2022-06-04 21:45:06 +00:00
|
|
|
machine.sleep(3)
|
2022-06-05 01:05:28 +00:00
|
|
|
machine.send_key("meta_l-ret")
|
|
|
|
machine.sleep(10)
|
2022-06-04 21:45:06 +00:00
|
|
|
machine.send_chars("whoami\n")
|
2022-06-05 01:05:28 +00:00
|
|
|
machine.sleep(3)
|
2022-06-04 21:45:06 +00:00
|
|
|
machine.wait_for_text("pub-solar")
|
|
|
|
machine.send_chars("test-wayland\n")
|
2022-06-05 01:05:28 +00:00
|
|
|
machine.sleep(3)
|
|
|
|
machine.screenshot("foot_wayland_info")
|
|
|
|
machine.send_key("meta_l-shift-q")
|
|
|
|
machine.wait_until_fails("pgrep foot")
|
2022-06-04 21:45:06 +00:00
|
|
|
'';
|
|
|
|
}
|