2022-01-20 06:48:05 +00:00
|
|
|
import ./make-test-python.nix ({ pkgs, ...}:
|
|
|
|
|
|
|
|
let
|
|
|
|
mkConfig = name: keys: ''
|
|
|
|
import XMonad
|
|
|
|
import XMonad.Operations (restart)
|
|
|
|
import XMonad.Util.EZConfig
|
|
|
|
import XMonad.Util.SessionStart
|
|
|
|
import Control.Monad (when)
|
|
|
|
import Text.Printf (printf)
|
|
|
|
import System.Posix.Process (executeFile)
|
|
|
|
import System.Info (arch,os)
|
|
|
|
import System.Environment (getArgs)
|
|
|
|
import System.FilePath ((</>))
|
|
|
|
|
2022-05-19 07:15:12 +00:00
|
|
|
main = do
|
|
|
|
dirs <- getDirectories
|
|
|
|
launch (def { startupHook = startup } `additionalKeysP` myKeys) dirs
|
2022-01-20 06:48:05 +00:00
|
|
|
|
|
|
|
startup = isSessionStart >>= \sessInit ->
|
|
|
|
spawn "touch /tmp/${name}"
|
|
|
|
>> if sessInit then setSessionStarted else spawn "xterm"
|
|
|
|
|
|
|
|
myKeys = [${builtins.concatStringsSep ", " keys}]
|
|
|
|
|
|
|
|
compiledConfig = printf "xmonad-%s-%s" arch os
|
|
|
|
|
2022-05-19 07:15:12 +00:00
|
|
|
compileRestart resume = do
|
|
|
|
dirs <- asks directories
|
|
|
|
|
|
|
|
whenX (recompile dirs True) $
|
2022-01-20 06:48:05 +00:00
|
|
|
when resume writeStateToFile
|
|
|
|
*> catchIO
|
|
|
|
( do
|
|
|
|
args <- getArgs
|
2022-05-19 07:15:12 +00:00
|
|
|
executeFile (cacheDir dirs </> compiledConfig) False args Nothing
|
2022-01-20 06:48:05 +00:00
|
|
|
)
|
|
|
|
'';
|
|
|
|
|
|
|
|
oldKeys =
|
|
|
|
[ ''("M-C-x", spawn "xterm")''
|
|
|
|
''("M-q", restart "xmonad" True)''
|
|
|
|
''("M-C-q", compileRestart True)''
|
|
|
|
''("M-C-t", spawn "touch /tmp/somefile")'' # create somefile
|
|
|
|
];
|
|
|
|
|
|
|
|
newKeys =
|
|
|
|
[ ''("M-C-x", spawn "xterm")''
|
|
|
|
''("M-q", restart "xmonad" True)''
|
|
|
|
''("M-C-q", compileRestart True)''
|
|
|
|
''("M-C-r", spawn "rm /tmp/somefile")'' # delete somefile
|
|
|
|
];
|
|
|
|
|
|
|
|
newConfig = pkgs.writeText "xmonad.hs" (mkConfig "newXMonad" newKeys);
|
|
|
|
in {
|
2017-09-04 18:03:20 +00:00
|
|
|
name = "xmonad";
|
2021-01-10 19:08:30 +00:00
|
|
|
meta = with pkgs.lib.maintainers; {
|
2022-01-20 16:17:03 +00:00
|
|
|
maintainers = [ nequissimus ivanbrennan ];
|
2017-09-04 18:03:20 +00:00
|
|
|
};
|
|
|
|
|
2022-03-20 23:15:30 +00:00
|
|
|
nodes.machine = { pkgs, ... }: {
|
2017-09-04 18:03:20 +00:00
|
|
|
imports = [ ./common/x11.nix ./common/user-account.nix ];
|
2020-01-26 22:41:19 +00:00
|
|
|
test-support.displayManager.auto.user = "alice";
|
2019-12-10 14:10:30 +00:00
|
|
|
services.xserver.displayManager.defaultSession = "none+xmonad";
|
2017-09-04 18:03:20 +00:00
|
|
|
services.xserver.windowManager.xmonad = {
|
|
|
|
enable = true;
|
2022-01-20 06:48:05 +00:00
|
|
|
enableConfiguredRecompile = true;
|
2017-09-04 18:03:20 +00:00
|
|
|
enableContribAndExtras = true;
|
|
|
|
extraPackages = with pkgs.haskellPackages; haskellPackages: [ xmobar ];
|
2022-01-20 06:48:05 +00:00
|
|
|
config = mkConfig "oldXMonad" oldKeys;
|
2017-09-04 18:03:20 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-11-07 02:18:26 +00:00
|
|
|
testScript = { nodes, ... }: let
|
|
|
|
user = nodes.machine.config.users.users.alice;
|
|
|
|
in ''
|
|
|
|
machine.wait_for_x()
|
|
|
|
machine.wait_for_file("${user.home}/.Xauthority")
|
|
|
|
machine.succeed("xauth merge ${user.home}/.Xauthority")
|
2019-12-13 16:16:59 +00:00
|
|
|
machine.send_key("alt-ctrl-x")
|
2019-11-07 02:18:26 +00:00
|
|
|
machine.wait_for_window("${user.name}.*machine")
|
|
|
|
machine.sleep(1)
|
2020-10-10 20:33:45 +00:00
|
|
|
machine.screenshot("terminal1")
|
2022-01-20 06:48:05 +00:00
|
|
|
machine.succeed("rm /tmp/oldXMonad")
|
2020-10-10 20:33:45 +00:00
|
|
|
machine.send_key("alt-q")
|
2022-01-20 06:48:05 +00:00
|
|
|
machine.wait_for_file("/tmp/oldXMonad")
|
2019-11-07 02:18:26 +00:00
|
|
|
machine.wait_for_window("${user.name}.*machine")
|
|
|
|
machine.sleep(1)
|
2020-10-10 20:33:45 +00:00
|
|
|
machine.screenshot("terminal2")
|
2022-01-20 06:48:05 +00:00
|
|
|
|
|
|
|
# /tmp/somefile should not exist yet
|
|
|
|
machine.fail("stat /tmp/somefile")
|
|
|
|
|
|
|
|
# original config has a keybinding that creates somefile
|
|
|
|
machine.send_key("alt-ctrl-t")
|
2022-01-20 14:58:05 +00:00
|
|
|
machine.wait_for_file("/tmp/somefile")
|
2022-01-20 06:48:05 +00:00
|
|
|
|
|
|
|
# set up the new config
|
|
|
|
machine.succeed("mkdir -p ${user.home}/.xmonad")
|
2022-05-19 07:15:12 +00:00
|
|
|
machine.copy_from_host("${newConfig}", "${user.home}/.config/xmonad/xmonad.hs")
|
2022-01-20 06:48:05 +00:00
|
|
|
|
|
|
|
# recompile xmonad using the new config
|
|
|
|
machine.send_key("alt-ctrl-q")
|
|
|
|
machine.wait_for_file("/tmp/newXMonad")
|
|
|
|
|
|
|
|
# new config has a keybinding that deletes somefile
|
|
|
|
machine.send_key("alt-ctrl-r")
|
2022-01-20 14:58:05 +00:00
|
|
|
machine.wait_until_fails("stat /tmp/somefile", timeout=30)
|
2022-01-20 06:48:05 +00:00
|
|
|
|
|
|
|
# restart with the old config, and confirm the old keybinding is back
|
|
|
|
machine.succeed("rm /tmp/oldXMonad")
|
|
|
|
machine.send_key("alt-q")
|
|
|
|
machine.wait_for_file("/tmp/oldXMonad")
|
|
|
|
machine.send_key("alt-ctrl-t")
|
2022-01-20 14:58:05 +00:00
|
|
|
machine.wait_for_file("/tmp/somefile")
|
2017-09-04 18:03:20 +00:00
|
|
|
'';
|
|
|
|
})
|