summary refs log tree commit diff
path: root/nixos/modules/services/x11
diff options
context:
space:
mode:
authorEric Sagnes <eric.sagnes@gmail.com>2016-11-14 00:23:25 +0900
committerEric Sagnes <eric.sagnes@gmail.com>2016-11-14 00:58:49 +0900
commit8ea1e9353702748efdae1baa9f457dd86612a79e (patch)
tree113c6fea6590aff7648cc1e25c21ca57bb53c6ad /nixos/modules/services/x11
parent8600e38bcaadef0d4b13e710d9c41b30abf0a9d7 (diff)
downloadnixlib-8ea1e9353702748efdae1baa9f457dd86612a79e.tar
nixlib-8ea1e9353702748efdae1baa9f457dd86612a79e.tar.gz
nixlib-8ea1e9353702748efdae1baa9f457dd86612a79e.tar.bz2
nixlib-8ea1e9353702748efdae1baa9f457dd86612a79e.tar.lz
nixlib-8ea1e9353702748efdae1baa9f457dd86612a79e.tar.xz
nixlib-8ea1e9353702748efdae1baa9f457dd86612a79e.tar.zst
nixlib-8ea1e9353702748efdae1baa9f457dd86612a79e.zip
i3 module: refactor
Diffstat (limited to 'nixos/modules/services/x11')
-rw-r--r--nixos/modules/services/x11/window-managers/i3.nix50
1 files changed, 28 insertions, 22 deletions
diff --git a/nixos/modules/services/x11/window-managers/i3.nix b/nixos/modules/services/x11/window-managers/i3.nix
index cfe9439b688c..f9c75e80db41 100644
--- a/nixos/modules/services/x11/window-managers/i3.nix
+++ b/nixos/modules/services/x11/window-managers/i3.nix
@@ -3,52 +3,58 @@
 with lib;
 
 let
-  wmCfg = config.services.xserver.windowManager;
+  cfg = config.services.xserver.windowManager.i3;
+in
+
+{
+  options.services.xserver.windowManager.i3 = {
+    enable = mkEnableOption "i3 window manager";
 
-  i3option = name: {
-    enable = mkEnableOption name;
     configFile = mkOption {
-      default = null;
-      type = types.nullOr types.path;
+      default     = null;
+      type        = with types; nullOr path;
       description = ''
         Path to the i3 configuration file.
         If left at the default value, $HOME/.i3/config will be used.
       '';
     };
+
     extraSessionCommands = mkOption {
-      default = "";
-      type = types.lines;
+      default     = "";
+      type        = types.lines;
       description = ''
         Shell commands executed just before i3 is started.
       '';
     };
+
+    package = mkOption {
+      type        = types.package;
+      default     = pkgs.i3;
+      defaultText = "pkgs.i3";
+      example     = "pkgs.i3-gaps";
+      description = ''
+        i3 package to use.
+      '';
+    };
   };
 
-  i3config = name: pkg: cfg: {
+  config = mkIf cfg.enable {
     services.xserver.windowManager.session = [{
-      inherit name;
+      name  = "i3";
       start = ''
         ${cfg.extraSessionCommands}
 
-        ${pkg}/bin/i3 ${optionalString (cfg.configFile != null)
+        ${cfg.package}/bin/i3 ${optionalString (cfg.configFile != null)
           "-c \"${cfg.configFile}\""
         } &
         waitPID=$!
       '';
     }];
-    environment.systemPackages = [ pkg ];
-  };
-
-in
-
-{
-  options.services.xserver.windowManager = {
-    i3 = i3option "i3";
-    i3-gaps = i3option "i3-gaps";
+    environment.systemPackages = [ cfg.package ];
   };
 
-  config = mkMerge [
-    (mkIf wmCfg.i3.enable (i3config "i3" pkgs.i3 wmCfg.i3))
-    (mkIf wmCfg.i3-gaps.enable (i3config "i3-gaps" pkgs.i3-gaps wmCfg.i3-gaps))
+  imports = [
+    (mkRemovedOptionModule [ "services" "xserver" "windowManager" "i3-gaps" "enable" ]
+      "Use services.xserver.windowManager.i3.enable and set services.xserver.windowManager.i3.package to pkgs.i3-gaps to use i3-gaps.")
   ];
 }