at 25.11-pre 1.7 kB view raw
1import ./make-test-python.nix ( 2 { pkgs, lib, ... }: 3 { 4 name = "sx"; 5 meta.maintainers = with lib.maintainers; [ 6 figsoda 7 thiagokokada 8 ]; 9 10 nodes.machine = 11 { ... }: 12 { 13 imports = [ ./common/user-account.nix ]; 14 15 environment.systemPackages = with pkgs; [ icewm ]; 16 17 services.getty.autologinUser = "alice"; 18 19 services.xserver = { 20 enable = true; 21 displayManager.sx.enable = true; 22 }; 23 24 # Create sxrc file on login and start sx 25 programs.bash.loginShellInit = 26 # bash 27 '' 28 mkdir -p "$HOME/.config/sx" 29 echo 'exec icewm' > "$HOME/.config/sx/sxrc" 30 chmod +x "$HOME/.config/sx/sxrc" 31 32 sx 33 ''; 34 }; 35 36 testScript = 37 { nodes, ... }: 38 let 39 user = nodes.machine.users.users.alice; 40 in 41 # python 42 '' 43 start_all() 44 45 machine.wait_for_unit("multi-user.target") 46 47 xauthority = "${user.home}/.local/share/sx/xauthority" 48 machine.wait_for_file(xauthority) 49 machine.succeed(f"xauth merge {xauthority}") 50 51 def icewm_is_visible(_last_try: bool) -> bool: 52 # sx will set DISPLAY as the TTY number we started, in this case 53 # TTY1: 54 # https://github.com/Earnestly/sx/blob/master/sx#L41. 55 # We can't use `machine.wait_for_window` here since we are running 56 # X as alice and not root. 57 return "IceWM" in machine.succeed("DISPLAY=:1 xwininfo -root -tree") 58 59 # Adding a retry logic to increase reliability 60 retry(icewm_is_visible) 61 ''; 62 } 63)