1 import ./make-test-python.nix ({ pkgs, ...}:
4 mkConfig = name: keys: ''
6 import XMonad.Operations (restart)
7 import XMonad.Util.EZConfig
8 import XMonad.Util.SessionStart
9 import Control.Monad (when)
10 import Text.Printf (printf)
11 import System.Posix.Process (executeFile)
12 import System.Info (arch,os)
13 import System.Environment (getArgs)
14 import System.FilePath ((</>))
17 dirs <- getDirectories
18 launch (def { startupHook = startup } `additionalKeysP` myKeys) dirs
20 startup = isSessionStart >>= \sessInit ->
21 spawn "touch /tmp/${name}"
22 >> if sessInit then setSessionStarted else spawn "xterm"
24 myKeys = [${builtins.concatStringsSep ", " keys}]
26 compiledConfig = printf "xmonad-%s-%s" arch os
28 compileRestart resume = do
29 dirs <- asks directories
31 whenX (recompile dirs True) $
32 when resume writeStateToFile
36 executeFile (cacheDir dirs </> compiledConfig) False args Nothing
41 [ ''("M-C-x", spawn "xterm")''
42 ''("M-q", restart "xmonad" True)''
43 ''("M-C-q", compileRestart True)''
44 ''("M-C-t", spawn "touch /tmp/somefile")'' # create somefile
48 [ ''("M-C-x", spawn "xterm")''
49 ''("M-q", restart "xmonad" True)''
50 ''("M-C-q", compileRestart True)''
51 ''("M-C-r", spawn "rm /tmp/somefile")'' # delete somefile
54 newConfig = pkgs.writeText "xmonad.hs" (mkConfig "newXMonad" newKeys);
57 meta = with pkgs.lib.maintainers; {
58 maintainers = [ nequissimus ivanbrennan ];
61 nodes.machine = { pkgs, ... }: {
62 imports = [ ./common/x11.nix ./common/user-account.nix ];
63 test-support.displayManager.auto.user = "alice";
64 services.displayManager.defaultSession = "none+xmonad";
65 services.xserver.windowManager.xmonad = {
67 enableConfiguredRecompile = true;
68 enableContribAndExtras = true;
69 extraPackages = with pkgs.haskellPackages; haskellPackages: [ xmobar ];
70 config = mkConfig "oldXMonad" oldKeys;
74 testScript = { nodes, ... }: let
75 user = nodes.machine.config.users.users.alice;
78 machine.wait_for_file("${user.home}/.Xauthority")
79 machine.succeed("xauth merge ${user.home}/.Xauthority")
80 machine.send_key("alt-ctrl-x")
81 machine.wait_for_window("${user.name}.*machine")
83 machine.screenshot("terminal1")
84 machine.succeed("rm /tmp/oldXMonad")
85 machine.send_key("alt-q")
86 machine.wait_for_file("/tmp/oldXMonad")
87 machine.wait_for_window("${user.name}.*machine")
89 machine.screenshot("terminal2")
91 # /tmp/somefile should not exist yet
92 machine.fail("stat /tmp/somefile")
94 # original config has a keybinding that creates somefile
95 machine.send_key("alt-ctrl-t")
96 machine.wait_for_file("/tmp/somefile")
98 # set up the new config
99 machine.succeed("mkdir -p ${user.home}/.xmonad")
100 machine.copy_from_host("${newConfig}", "${user.home}/.config/xmonad/xmonad.hs")
102 # recompile xmonad using the new config
103 machine.send_key("alt-ctrl-q")
104 machine.wait_for_file("/tmp/newXMonad")
106 # new config has a keybinding that deletes somefile
107 machine.send_key("alt-ctrl-r")
108 machine.wait_until_fails("stat /tmp/somefile", timeout=30)
110 # restart with the old config, and confirm the old keybinding is back
111 machine.succeed("rm /tmp/oldXMonad")
112 machine.send_key("alt-q")
113 machine.wait_for_file("/tmp/oldXMonad")
114 machine.send_key("alt-ctrl-t")
115 machine.wait_for_file("/tmp/somefile")