i3-gaps: add as window manager

Closes #15917

authored by Franz Thoma and committed by obadz 688d7cd3 b60b7eea

+34 -28
+34 -28
nixos/modules/services/x11/window-managers/i3.nix
··· 3 with lib; 4 5 let 6 - cfg = config.services.xserver.windowManager.i3; 7 - in 8 9 - { 10 - options = { 11 - services.xserver.windowManager.i3 = { 12 - enable = mkEnableOption "i3"; 13 - 14 - configFile = mkOption { 15 - default = null; 16 - type = types.nullOr types.path; 17 - description = '' 18 - Path to the i3 configuration file. 19 - If left at the default value, $HOME/.i3/config will be used. 20 - ''; 21 - }; 22 }; 23 }; 24 25 - config = mkIf cfg.enable { 26 - services.xserver.windowManager = { 27 - session = [{ 28 - name = "i3"; 29 - start = '' 30 - ${pkgs.i3}/bin/i3 ${optionalString (cfg.configFile != null) 31 - "-c \"${cfg.configFile}\"" 32 - } & 33 - waitPID=$! 34 - ''; 35 - }]; 36 - }; 37 - environment.systemPackages = with pkgs; [ i3 ]; 38 }; 39 }
··· 3 with lib; 4 5 let 6 + wmCfg = config.services.xserver.windowManager; 7 8 + i3option = name: { 9 + enable = mkEnableOption name; 10 + configFile = mkOption { 11 + default = null; 12 + type = types.nullOr types.path; 13 + description = '' 14 + Path to the i3 configuration file. 15 + If left at the default value, $HOME/.i3/config will be used. 16 + ''; 17 }; 18 }; 19 20 + i3config = name: pkg: cfg: { 21 + services.xserver.windowManager.session = [{ 22 + inherit name; 23 + start = '' 24 + ${pkg}/bin/i3 ${optionalString (cfg.configFile != null) 25 + "-c \"${cfg.configFile}\"" 26 + } & 27 + waitPID=$! 28 + ''; 29 + }]; 30 + environment.systemPackages = [ pkg ]; 31 + }; 32 + 33 + in 34 + 35 + { 36 + options.services.xserver.windowManager = { 37 + i3 = i3option "i3"; 38 + i3-gaps = i3option "i3-gaps"; 39 }; 40 + 41 + config = mkMerge [ 42 + (mkIf wmCfg.i3.enable (i3config "i3" pkgs.i3 wmCfg.i3)) 43 + (mkIf wmCfg.i3-gaps.enable (i3config "i3-gaps" pkgs.i3-gaps wmCfg.i3-gaps)) 44 + ]; 45 }