git.iko.soy/typeable/nixpkgs
on master help sign in
xmonad service: add .config option
commit3eefc0b90923c02adad9d841b34e22c14adfdc08 authorlassulus <lassulus@lassul.us> dateWed 28 Nov 2018, 23:08 (8 years ago) parente814fba
2 files changed+42−1
nixos/modules/services/x11/window-managers/xmonad.nix+32−1 nixos/tests/xmonad.nix+10
nixos/modules/services/x11/window-managers/xmonad.nix+32−1
@@ -10,6 +10,14 @@ let
1010 optionals cfg.enableContribAndExtras
1111 [ self.xmonad-contrib self.xmonad-extras ];
1212 };
13+ xmonadBin = pkgs.writers.writeHaskell "xmonad" {
14+ ghc = cfg.haskellPackages.ghc;
15+ libraries = [ cfg.haskellPackages.xmonad ] ++
16+ cfg.extraPackages cfg.haskellPackages ++
17+ optionals cfg.enableContribAndExtras
18+ (with cfg.haskellPackages; [ xmonad-contrib xmonad-extras ]);
19+ } cfg.config;
20+
1321in
1422{
1523 options = {
@@ -48,13 +56,36 @@ in
4856 type = lib.types.bool;
4957 description = "Enable xmonad-{contrib,extras} in Xmonad.";
5058 };
59+
60+ config = mkOption {
61+ default = null;
62+ type = with lib.types; nullOr (either path string);
63+ description = ''
64+ Configuration from which XMonad gets compiled. If no value
65+ is specified, the xmonad config from $HOME/.xmonad is taken.
66+ If you use xmonad --recompile, $HOME/.xmonad will be taken as
67+ the configuration, but on the next restart of display-manager
68+ this config will be reapplied.
69+ '';
70+ example = ''
71+ import XMonad
72+
73+ main = launch defaultConfig
74+ { modMask = mod4Mask -- Use Super instead of Alt
75+ , terminal = "urxvt"
76+ }
77+ '';
78+ };
5179 };
5280 };
5381 config = mkIf cfg.enable {
5482 services.xserver.windowManager = {
5583 session = [{
5684 name = "xmonad";
57− start = ''
85+ start = if (cfg.config != null) then ''
86+ ${xmonadBin}
87+ waitPID=$!
88+ '' else ''
5889 ${xmonad}/bin/xmonad &
5990 waitPID=$!
6091 '';
nixos/tests/xmonad.nix+10
@@ -12,6 +12,12 @@ import ./make-test.nix ({ pkgs, ...} : {
1212 enable = true;
1313 enableContribAndExtras = true;
1414 extraPackages = with pkgs.haskellPackages; haskellPackages: [ xmobar ];
15+ config = ''
16+ import XMonad
17+ import XMonad.Util.EZConfig
18+ main = launch $ def `additionalKeysP` myKeys
19+ myKeys = [ ("M-C-x", spawn "xterm") ]
20+ '';
1521 };
1622 };
1723
@@ -19,6 +25,10 @@ import ./make-test.nix ({ pkgs, ...} : {
1925 $machine->waitForX;
2026 $machine->waitForFile("/home/alice/.Xauthority");
2127 $machine->succeed("xauth merge ~alice/.Xauthority");
28+ $machine->sendKeys("alt-ctrl-x");
29+ $machine->waitForWindow(qr/machine.*alice/);
30+ $machine->sleep(1);
31+ $machine->screenshot("terminal");
2232 $machine->waitUntilSucceeds("xmonad --restart");
2333 $machine->sleep(3);
2434 $machine->sendKeys("alt-shift-ret");