1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7 8with lib; 9 10let 11 cfg = config.services.xserver.windowManager.exwm; 12 loadScript = pkgs.writeText "emacs-exwm-load" '' 13 ${cfg.loadScript} 14 ''; 15 packages = epkgs: cfg.extraPackages epkgs ++ [ epkgs.exwm ]; 16 exwm-emacs = cfg.package.pkgs.withPackages packages; 17in 18{ 19 20 imports = [ 21 (mkRemovedOptionModule [ "services" "xserver" "windowManager" "exwm" "enableDefaultConfig" ] 22 "The upstream EXWM project no longer provides a default configuration, instead copy (parts of) exwm-config.el to your local config." 23 ) 24 ]; 25 26 options = { 27 services.xserver.windowManager.exwm = { 28 enable = mkEnableOption "exwm"; 29 loadScript = mkOption { 30 default = "(require 'exwm)"; 31 type = types.lines; 32 example = '' 33 (require 'exwm) 34 (exwm-enable) 35 ''; 36 description = '' 37 Emacs lisp code to be run after loading the user's init 38 file. 39 ''; 40 }; 41 package = mkPackageOption pkgs "Emacs" { 42 default = "emacs"; 43 example = [ "emacs-gtk" ]; 44 }; 45 extraPackages = mkOption { 46 type = types.functionTo (types.listOf types.package); 47 default = epkgs: [ ]; 48 defaultText = literalExpression "epkgs: []"; 49 example = literalExpression '' 50 epkgs: [ 51 epkgs.emms 52 epkgs.magit 53 epkgs.proofgeneral 54 ] 55 ''; 56 description = '' 57 Extra packages available to Emacs. The value must be a 58 function which receives the attrset defined in 59 {var}`emacs.pkgs` as the sole argument. 60 ''; 61 }; 62 }; 63 }; 64 65 config = mkIf cfg.enable { 66 services.xserver.windowManager.session = singleton { 67 name = "exwm"; 68 start = '' 69 ${exwm-emacs}/bin/emacs -l ${loadScript} 70 ''; 71 }; 72 environment.systemPackages = [ exwm-emacs ]; 73 }; 74}