summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranz Pletz <fpletz@fnordicwalking.de>2019-05-24 18:37:55 +0000
committerGitHub <noreply@github.com>2019-05-24 18:37:55 +0000
commit5fa8cd257a22380315c56626fee16cee3d33e121 (patch)
tree08f9f62c40480745cb80fe452ea522586efe217e
parent32c25b4f1d09fcb08b9ef0a409243c3da5db1101 (diff)
parent3eefc0b90923c02adad9d841b34e22c14adfdc08 (diff)
downloadnixpkgs-5fa8cd257a22380315c56626fee16cee3d33e121.tar
nixpkgs-5fa8cd257a22380315c56626fee16cee3d33e121.tar.gz
nixpkgs-5fa8cd257a22380315c56626fee16cee3d33e121.tar.bz2
nixpkgs-5fa8cd257a22380315c56626fee16cee3d33e121.tar.lz
nixpkgs-5fa8cd257a22380315c56626fee16cee3d33e121.tar.xz
nixpkgs-5fa8cd257a22380315c56626fee16cee3d33e121.tar.zst
nixpkgs-5fa8cd257a22380315c56626fee16cee3d33e121.zip
Merge pull request #51206 from krebs/xmonad-config
xmonad service: add .config option
-rw-r--r--nixos/modules/services/x11/window-managers/xmonad.nix33
-rw-r--r--nixos/tests/xmonad.nix10
2 files changed, 42 insertions, 1 deletions
diff --git a/nixos/modules/services/x11/window-managers/xmonad.nix b/nixos/modules/services/x11/window-managers/xmonad.nix
index 43de746ab1f..a6055f26789 100644
--- a/nixos/modules/services/x11/window-managers/xmonad.nix
+++ b/nixos/modules/services/x11/window-managers/xmonad.nix
@@ -10,6 +10,14 @@ let
                      optionals cfg.enableContribAndExtras
                      [ self.xmonad-contrib self.xmonad-extras ];
   };
+  xmonadBin = pkgs.writers.writeHaskell "xmonad" {
+    ghc = cfg.haskellPackages.ghc;
+    libraries = [ cfg.haskellPackages.xmonad ] ++
+                cfg.extraPackages cfg.haskellPackages ++
+                optionals cfg.enableContribAndExtras
+                (with cfg.haskellPackages; [ xmonad-contrib xmonad-extras ]);
+  } cfg.config;
+
 in
 {
   options = {
@@ -48,13 +56,36 @@ in
         type = lib.types.bool;
         description = "Enable xmonad-{contrib,extras} in Xmonad.";
       };
+
+      config = mkOption {
+        default = null;
+        type = with lib.types; nullOr (either path string);
+        description = ''
+          Configuration from which XMonad gets compiled. If no value
+          is specified, the xmonad config from $HOME/.xmonad is taken.
+          If you use xmonad --recompile, $HOME/.xmonad will be taken as
+          the configuration, but on the next restart of display-manager
+          this config will be reapplied.
+        '';
+        example = ''
+          import XMonad
+
+          main = launch defaultConfig
+                 { modMask = mod4Mask -- Use Super instead of Alt
+                 , terminal = "urxvt"
+                 }
+        '';
+      };
     };
   };
   config = mkIf cfg.enable {
     services.xserver.windowManager = {
       session = [{
         name = "xmonad";
-        start = ''
+        start = if (cfg.config != null) then ''
+          ${xmonadBin}
+          waitPID=$!
+        '' else ''
           ${xmonad}/bin/xmonad &
           waitPID=$!
         '';
diff --git a/nixos/tests/xmonad.nix b/nixos/tests/xmonad.nix
index 6d6db6b0ea9..4d3bc28cd34 100644
--- a/nixos/tests/xmonad.nix
+++ b/nixos/tests/xmonad.nix
@@ -12,6 +12,12 @@ import ./make-test.nix ({ pkgs, ...} : {
       enable = true;
       enableContribAndExtras = true;
       extraPackages = with pkgs.haskellPackages; haskellPackages: [ xmobar ];
+      config = ''
+        import XMonad
+        import XMonad.Util.EZConfig
+        main = launch $ def `additionalKeysP` myKeys
+        myKeys = [ ("M-C-x", spawn "xterm") ]
+      '';
     };
   };
 
@@ -19,6 +25,10 @@ import ./make-test.nix ({ pkgs, ...} : {
     $machine->waitForX;
     $machine->waitForFile("/home/alice/.Xauthority");
     $machine->succeed("xauth merge ~alice/.Xauthority");
+    $machine->sendKeys("alt-ctrl-x");
+    $machine->waitForWindow(qr/machine.*alice/);
+    $machine->sleep(1);
+    $machine->screenshot("terminal");
     $machine->waitUntilSucceeds("xmonad --restart");
     $machine->sleep(3);
     $machine->sendKeys("alt-shift-ret");