at master 2.0 kB view raw
1{ pkgs, lib, ... }: 2 3let 4 cagebreakConfigfile = pkgs.writeText "config" '' 5 workspaces 1 6 escape C-t 7 bind t exec env DISPLAY=:0 ${pkgs.xterm}/bin/xterm -cm -pc 8 ''; 9in 10{ 11 name = "cagebreak"; 12 meta = with pkgs.lib.maintainers; { 13 maintainers = [ berbiche ]; 14 }; 15 16 nodes.machine = 17 { config, ... }: 18 { 19 # Automatically login on tty1 as a normal user: 20 imports = [ ./common/user-account.nix ]; 21 services.getty.autologinUser = "alice"; 22 programs.bash.loginShellInit = '' 23 if [ "$(tty)" = "/dev/tty1" ]; then 24 set -e 25 26 mkdir -p ~/.config/cagebreak 27 cp -f ${cagebreakConfigfile} ~/.config/cagebreak/config 28 29 cagebreak 30 fi 31 ''; 32 33 hardware.graphics.enable = true; 34 programs.xwayland.enable = true; 35 security.polkit.enable = true; 36 environment.systemPackages = [ 37 pkgs.cagebreak 38 pkgs.wayland-utils 39 ]; 40 41 # Need to switch to a different GPU driver than the default one (-vga std) so that Cagebreak can launch: 42 virtualisation.qemu.options = [ "-vga none -device virtio-gpu-pci" ]; 43 }; 44 45 enableOCR = true; 46 47 testScript = 48 { nodes, ... }: 49 let 50 user = nodes.machine.config.users.users.alice; 51 XDG_RUNTIME_DIR = "/run/user/${toString user.uid}"; 52 in 53 '' 54 start_all() 55 machine.wait_for_unit("multi-user.target") 56 machine.wait_for_file("${XDG_RUNTIME_DIR}/wayland-0") 57 58 with subtest("ensure wayland works with wayinfo from wallutils"): 59 print(machine.succeed("env XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR} wayland-info")) 60 61 # TODO: Fix the XWayland test (log the cagebreak output to debug): 62 # with subtest("ensure xwayland works with xterm"): 63 # machine.send_key("ctrl-t") 64 # machine.send_key("t") 65 # machine.wait_until_succeeds("pgrep xterm") 66 # machine.wait_for_text("${user.name}@machine") 67 # machine.screenshot("screen") 68 # machine.send_key("ctrl-d") 69 ''; 70}