1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 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 extraSessionCommands = mkOption { 19 default = ""; 20 type = types.lines; 21 description = '' 22 Shell commands executed just before i3 is started. 23 ''; 24 }; 25 }; 26 27 i3config = name: pkg: cfg: { 28 services.xserver.windowManager.session = [{ 29 inherit name; 30 start = '' 31 ${cfg.extraSessionCommands} 32 33 ${pkg}/bin/i3 ${optionalString (cfg.configFile != null) 34 "-c \"${cfg.configFile}\"" 35 } & 36 waitPID=$! 37 ''; 38 }]; 39 environment.systemPackages = [ pkg ]; 40 }; 41 42in 43 44{ 45 options.services.xserver.windowManager = { 46 i3 = i3option "i3"; 47 i3-gaps = i3option "i3-gaps"; 48 }; 49 50 config = mkMerge [ 51 (mkIf wmCfg.i3.enable (i3config "i3" pkgs.i3 wmCfg.i3)) 52 (mkIf wmCfg.i3-gaps.enable (i3config "i3-gaps" pkgs.i3-gaps wmCfg.i3-gaps)) 53 ]; 54}