1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-12-03 07:31:03 +01:00

emacs: Support socket activation via systemd

Add 'services.emacs.socketActivation.enable' for generating an
'emacs.socket' systemd unit.

Emacs since version 26 has supported socket activation, whereby an
external process manager such as systemd listens on a socket and passes
it to the Emacs daemon when the manager launches it. This improves
startup time of the user session and avoids launching the daemon when not
needed, for example when launching the user session via SSH.

This implementation hard-codes the socket path to the default for the
version of 'programs.emacs.finalPackage', because systemd does not
perform shell expansion in the socket unit's 'ListenStream' parameter
and it seems like an advanced use-case to change the socket path. Shell
expansion would be desirable as the socket path usually resides in
directories such as $XDG_RUNTIME_DIR or $TMPDIR.

Tests were added to verify behavior in the following cases:

- Emacs service with socket activation disabled
- Emacs 26 with socket activation enabled
- Emacs 27 with socket activation enabled

PR #1314
This commit is contained in:
Tad Fisher 2020-06-08 14:01:17 -07:00 committed by Robert Helgesson
parent 02c1f8d416
commit 3815248786
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
13 changed files with 276 additions and 29 deletions

View file

@ -0,0 +1,9 @@
[Service]
ExecStart=@emacs@/bin/emacs --fg-daemon="%t/emacs/server"
ExecStop=@emacs@/bin/emacsclient --eval '(kill-emacs 0)'
Restart=on-failure
[Unit]
Description=Emacs: the extensible, self-documenting text editor
Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/
X-RestartIfChanged=false