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 type = lib.types.bool;
25 description = "Enable an uncustomised exwm configuration.";
26 };
27 extraPackages = mkOption {
28 default = self: [];
29 example = literalExample ''
30 epkgs: [
31 epkgs.emms
32 epkgs.magit
33 epkgs.proofgeneral
34 ]
35 '';
36 description = ''
37 Extra packages available to Emacs. The value must be a
38 function which receives the attrset defined in
39 <varname>emacsPackages</varname> as the sole argument.
40 '';
41 };
42 };
43 };
44
45 config = mkIf cfg.enable {
46 services.xserver.windowManager.session = singleton {
47 name = "exwm";
48 start = ''
49 ${exwm-emacs}/bin/emacs -l ${loadScript}
50 '';
51 };
52 environment.systemPackages = [ exwm-emacs ];
53 };
54}