@ -1,4 +1,55 @@
import ./make-test-python.nix ( { pkgs , . . . } : {
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 ( ( < / > ) )
main = launch $ def { startupHook = startup } ` additionalKeysP ` myKeys
startup = isSessionStart > >= \ sessInit ->
spawn " t o u c h / t m p / ${ name } "
> > if sessInit then setSessionStarted else spawn " x t e r m "
myKeys = [ $ { builtins . concatStringsSep " , " keys } ]
compiledConfig = printf " x m o n a d - % s - % s " arch os
compileRestart resume =
whenX ( recompile True ) $
when resume writeStateToFile
* > catchIO
( do
dir < - getXMonadDataDir
args < - getArgs
executeFile ( dir < / > compiledConfig ) False args Nothing
)
'' ;
oldKeys =
[ '' ( " M - C - x " , s p a w n " x t e r m " ) ''
'' ( " M - q " , r e s t a r t " x m o n a d " T r u e ) ''
'' ( " M - C - q " , c o m p i l e R e s t a r t T r u e ) ''
'' ( " M - C - t " , s p a w n " t o u c h / t m p / s o m e f i l e " ) '' # create somefile
] ;
newKeys =
[ '' ( " M - C - x " , s p a w n " x t e r m " ) ''
'' ( " M - q " , r e s t a r t " x m o n a d " T r u e ) ''
'' ( " M - C - q " , c o m p i l e R e s t a r t T r u e ) ''
'' ( " M - C - r " , s p a w n " r m / t m p / s o m e f i l e " ) '' # delete somefile
] ;
newConfig = pkgs . writeText " x m o n a d . h s " ( mkConfig " n e w X M o n a d " newKeys ) ;
in {
name = " x m o n a d " ;
meta = with pkgs . lib . maintainers ; {
maintainers = [ nequissimus ] ;
@ -10,21 +61,10 @@ import ./make-test-python.nix ({ pkgs, ...} : {
services . xserver . displayManager . defaultSession = " n o n e + x m o n a d " ;
services . xserver . windowManager . xmonad = {
enable = true ;
enableConfiguredRecompile = true ;
enableContribAndExtras = true ;
extraPackages = with pkgs . haskellPackages ; haskellPackages : [ xmobar ] ;
config = ''
import XMonad
import XMonad . Operations ( restart )
import XMonad . Util . EZConfig
import XMonad . Util . SessionStart
main = launch $ def { startupHook = startup } ` additionalKeysP ` myKeys
startup = isSessionStart > >= \ sessInit ->
if sessInit then setSessionStarted else spawn " x t e r m "
myKeys = [ ( " M - C - x " , spawn " x t e r m " ) , ( " M - q " , restart " x m o n a d " True ) ]
'' ;
config = mkConfig " o l d X M o n a d " oldKeys ;
} ;
} ;
@ -38,10 +78,40 @@ import ./make-test-python.nix ({ pkgs, ...} : {
machine . wait_for_window ( " ${ user . name } . * m a c h i n e " )
machine . sleep ( 1 )
machine . screenshot ( " t e r m i n a l 1 " )
machine . succeed ( " r m / t m p / o l d X M o n a d " )
machine . send_key ( " a l t - q " )
machine . sleep ( 3 )
machine . wait_for_file ( " / t m p / o l d X M o n a d " )
machine . wait_for_window ( " ${ user . name } . * m a c h i n e " )
machine . sleep ( 1 )
machine . screenshot ( " t e r m i n a l 2 " )
# /tmp/somefile should not exist yet
machine . fail ( " s t a t / t m p / s o m e f i l e " )
# original config has a keybinding that creates somefile
machine . send_key ( " a l t - c t r l - t " )
machine . sleep ( 1 )
machine . succeed ( " s t a t / t m p / s o m e f i l e " )
# set up the new config
machine . succeed ( " m k d i r - p ${ user . home } / . x m o n a d " )
machine . copy_from_host ( " ${ newConfig } " , " ${ user . home } / . x m o n a d / x m o n a d . h s " )
# recompile xmonad using the new config
machine . send_key ( " a l t - c t r l - q " )
machine . wait_for_file ( " / t m p / n e w X M o n a d " )
# new config has a keybinding that deletes somefile
machine . send_key ( " a l t - c t r l - r " )
machine . sleep ( 1 )
machine . fail ( " s t a t / t m p / s o m e f i l e " )
# restart with the old config, and confirm the old keybinding is back
machine . succeed ( " r m / t m p / o l d X M o n a d " )
machine . send_key ( " a l t - q " )
machine . wait_for_file ( " / t m p / o l d X M o n a d " )
machine . send_key ( " a l t - c t r l - t " )
machine . sleep ( 1 )
machine . succeed ( " s t a t / t m p / s o m e f i l e " )
'' ;
} )