1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 cfg = config.services.xserver.windowManager.exwm; 7 loadScript = pkgs.writeText "emacs-exwm-load" '' 8 (require 'exwm) 9 ${optionalString cfg.enableDefaultConfig '' 10 (require 'exwm-config) 11 (exwm-config-default) 12 ''} 13 ''; 14 packages = epkgs: cfg.extraPackages epkgs ++ [ epkgs.exwm ]; 15 exwm-emacs = pkgs.emacsWithPackages packages; 16in 17 18{ 19 options = { 20 services.xserver.windowManager.exwm = { 21 enable = mkEnableOption "exwm"; 22 enableDefaultConfig = mkOption { 23 default = true; 24 example = false; 25 type = lib.types.bool; 26 description = "Enable an uncustomised exwm configuration."; 27 }; 28 extraPackages = mkOption { 29 default = self: []; 30 example = literalExample '' 31 epkgs: [ 32 epkgs.emms 33 epkgs.magit 34 epkgs.proofgeneral 35 ] 36 ''; 37 description = '' 38 Extra packages available to Emacs. The value must be a 39 function which receives the attrset defined in 40 <varname>emacsPackages</varname> as the sole argument. 41 ''; 42 }; 43 }; 44 }; 45 46 config = mkIf cfg.enable { 47 services.xserver.windowManager.session = singleton { 48 name = "exwm"; 49 start = '' 50 ${exwm-emacs}/bin/emacs -l ${loadScript} 51 ''; 52 }; 53 environment.systemPackages = [ exwm-emacs ]; 54 }; 55}