emacs: Remove obsolete socket file workaround

This commit is contained in:
Rodney Lorrimar 2023-11-09 15:16:01 +08:00 committed by Robert Helgesson
parent 54586daa59
commit 47226ec7e7
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
5 changed files with 18 additions and 4 deletions

View file

@ -12,6 +12,10 @@ let
clientWMClass = clientWMClass =
if versionAtLeast emacsVersion "28" then "Emacsd" else "Emacs"; if versionAtLeast emacsVersion "28" then "Emacsd" else "Emacs";
# Workaround for https://debbugs.gnu.org/47511
needsSocketWorkaround = versionOlder emacsVersion "28"
&& cfg.socketActivation.enable;
# Adapted from upstream emacs.desktop # Adapted from upstream emacs.desktop
clientDesktopItem = pkgs.writeTextDir "share/applications/emacsclient.desktop" clientDesktopItem = pkgs.writeTextDir "share/applications/emacsclient.desktop"
(generators.toINI { } { (generators.toINI { } {
@ -128,7 +132,7 @@ in {
# Avoid killing the Emacs session, which may be full of # Avoid killing the Emacs session, which may be full of
# unsaved buffers. # unsaved buffers.
X-RestartIfChanged = false; X-RestartIfChanged = false;
} // optionalAttrs (cfg.socketActivation.enable) { } // optionalAttrs needsSocketWorkaround {
# Emacs deletes its socket when shutting down, which systemd doesn't # Emacs deletes its socket when shutting down, which systemd doesn't
# handle, resulting in a server without a socket. # handle, resulting in a server without a socket.
# See https://github.com/nix-community/home-manager/issues/2018 # See https://github.com/nix-community/home-manager/issues/2018
@ -157,7 +161,7 @@ in {
SuccessExitStatus = 15; SuccessExitStatus = 15;
Restart = "on-failure"; Restart = "on-failure";
} // optionalAttrs (cfg.socketActivation.enable) { } // optionalAttrs needsSocketWorkaround {
# Use read-only directory permissions to prevent emacs from # Use read-only directory permissions to prevent emacs from
# deleting systemd's socket file before exiting. # deleting systemd's socket file before exiting.
ExecStartPost = ExecStartPost =

View file

@ -32,7 +32,7 @@
${ ${
pkgs.substituteAll { pkgs.substituteAll {
inherit (pkgs) runtimeShell coreutils; inherit (pkgs) runtimeShell coreutils;
src = ./emacs-socket-emacs.service; src = ./emacs-socket-27-emacs.service;
} }
} }

View file

@ -0,0 +1,10 @@
[Service]
ExecStart=@runtimeShell@ -l -c "@emacs@/bin/emacs --fg-daemon='%t/emacs/server' '-f' 'exwm-enable'"
Restart=on-failure
SuccessExitStatus=15
Type=notify
[Unit]
Description=Emacs text editor
Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/
X-RestartIfChanged=false

View file

@ -32,7 +32,7 @@
${ ${
pkgs.substituteAll { pkgs.substituteAll {
inherit (pkgs) runtimeShell coreutils; inherit (pkgs) runtimeShell coreutils;
src = ./emacs-socket-emacs.service; src = ./emacs-socket-28-emacs.service;
} }
} }