From 47226ec7e791d8080a63c170ab50bf27539117cf Mon Sep 17 00:00:00 2001 From: Rodney Lorrimar Date: Thu, 9 Nov 2023 15:16:01 +0800 Subject: [PATCH] emacs: Remove obsolete socket file workaround --- modules/services/emacs.nix | 8 ++++++-- ...ket-emacs.service => emacs-socket-27-emacs.service} | 0 tests/modules/services/emacs/emacs-socket-27.nix | 2 +- .../services/emacs/emacs-socket-28-emacs.service | 10 ++++++++++ tests/modules/services/emacs/emacs-socket-28.nix | 2 +- 5 files changed, 18 insertions(+), 4 deletions(-) rename tests/modules/services/emacs/{emacs-socket-emacs.service => emacs-socket-27-emacs.service} (100%) create mode 100644 tests/modules/services/emacs/emacs-socket-28-emacs.service diff --git a/modules/services/emacs.nix b/modules/services/emacs.nix index 64c6c6eee..394e36590 100644 --- a/modules/services/emacs.nix +++ b/modules/services/emacs.nix @@ -12,6 +12,10 @@ let clientWMClass = 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 clientDesktopItem = pkgs.writeTextDir "share/applications/emacsclient.desktop" (generators.toINI { } { @@ -128,7 +132,7 @@ in { # Avoid killing the Emacs session, which may be full of # unsaved buffers. X-RestartIfChanged = false; - } // optionalAttrs (cfg.socketActivation.enable) { + } // optionalAttrs needsSocketWorkaround { # Emacs deletes its socket when shutting down, which systemd doesn't # handle, resulting in a server without a socket. # See https://github.com/nix-community/home-manager/issues/2018 @@ -157,7 +161,7 @@ in { SuccessExitStatus = 15; Restart = "on-failure"; - } // optionalAttrs (cfg.socketActivation.enable) { + } // optionalAttrs needsSocketWorkaround { # Use read-only directory permissions to prevent emacs from # deleting systemd's socket file before exiting. ExecStartPost = diff --git a/tests/modules/services/emacs/emacs-socket-emacs.service b/tests/modules/services/emacs/emacs-socket-27-emacs.service similarity index 100% rename from tests/modules/services/emacs/emacs-socket-emacs.service rename to tests/modules/services/emacs/emacs-socket-27-emacs.service diff --git a/tests/modules/services/emacs/emacs-socket-27.nix b/tests/modules/services/emacs/emacs-socket-27.nix index c7282bdb8..70e85551b 100644 --- a/tests/modules/services/emacs/emacs-socket-27.nix +++ b/tests/modules/services/emacs/emacs-socket-27.nix @@ -32,7 +32,7 @@ ${ pkgs.substituteAll { inherit (pkgs) runtimeShell coreutils; - src = ./emacs-socket-emacs.service; + src = ./emacs-socket-27-emacs.service; } } diff --git a/tests/modules/services/emacs/emacs-socket-28-emacs.service b/tests/modules/services/emacs/emacs-socket-28-emacs.service new file mode 100644 index 000000000..153f5d8fe --- /dev/null +++ b/tests/modules/services/emacs/emacs-socket-28-emacs.service @@ -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 diff --git a/tests/modules/services/emacs/emacs-socket-28.nix b/tests/modules/services/emacs/emacs-socket-28.nix index c822f535e..49887c330 100644 --- a/tests/modules/services/emacs/emacs-socket-28.nix +++ b/tests/modules/services/emacs/emacs-socket-28.nix @@ -32,7 +32,7 @@ ${ pkgs.substituteAll { inherit (pkgs) runtimeShell coreutils; - src = ./emacs-socket-emacs.service; + src = ./emacs-socket-28-emacs.service; } }