Hey! It’s been a couple days, but I did finally get around to at least
trying to get some work done on this.
I tried copying the EXWM nixpkgs module and changing it for my own
purposes. This seems to have worked, except for the fact that I
couldn’t get it to build. There was a build error that appeared when
compiling Emacs. Don’t know whether it’s worth anything, but it built
just fine when using nixos-rebuild build-vm
instead of
nixos-rebuild switch
. Any thoughts on that, @mattchrist? If not,
you’re free to see if this works for you. Based on the issue mentioned
above, I thought it’d be nice if the module would let you build
packages with Emacs, so I expect something like the following:
let
my-exwm-emacs = pkgs.emacsWithPackagesFromUsePackage {
config = /home/<user>/.emacs.d/init.el;
package = pkgs.emacsGcc;
};
exwm-load-script = ''
(require 'exwm)
(exwm-init)
'';
in {
services.xserver.windowManager.myExwm = {
enable = true;
enableDefaultConfig = false;
executable = my-exwm-emacs;
loadScript = exwm-load-script;
};
}
Customized exwm module
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.xserver.windowManager.myExwm;
loadScript = pkgs.writeText "emacs-exwm-load" ''
${cfg.loadScript}
${optionalString cfg.enableDefaultConfig ''
(require 'exwm-config)
(exwm-config-default)
''}
'';
exwm-emacs = cfg.executable;
in {
options = {
services.xserver.windowManager.myExwm = {
enable = mkEnableOption "exwm";
loadScript = mkOption {
default = "(require 'exwm)";
example = literalExample ''
(require 'exwm)
(exwm-enable)
'';
description = ''
Emacs lisp code to be run after loading the user's init
file. If enableDefaultConfig is true, this will be run
before loading the default config.
'';
};
enableDefaultConfig = mkOption {
default = true;
type = lib.types.bool;
description = "Enable an uncustomised exwm configuration.";
};
executable = mkOption {
default = pkgs.emacsWithPackages (epkgs: [ epkgs.exwm ]);
example = literalExample ''
emacsWithPackagesFromUsePackage {
config = ./init.el;
package = pkgs.emacsGit;
};
'';
description = ''
Which emacs executable to use, including packages.
'';
};
};
};
config = mkIf cfg.enable {
services.xserver.windowManager.session = singleton {
name = "exwm";
start = ''
${exwm-emacs}/bin/emacs -l ${loadScript}
'';
};
environment.systemPackages = [ exwm-emacs ];
};
}
@codygman Thanks for your input too! I’ve never used home-manager
before, but gave it a little go now. Unfortunately I’m not quite
familiar enough with Nix to understand how it all works and hangs
together, so I don’t quite understand how to make it work with my
window manager, though I did see the section on graphical
services
in the readme. I’ll play around with it some more later, though. I’d
ask a few questions, but I’m not sure where to start yet, so I’ll save
that for later if you don’t mind.
Cheers!