mirror of
https://github.com/nix-community/home-manager
synced 2024-11-10 07:04:17 +00:00
services/emacs: Prevent deletion of socket file
When running a socket-activated emacs service, we don't want emacs to remove the socket file after exiting, because then subsequent invocations of `emacsclient` won't be able to use the socket to start emacs.service again.
This commit is contained in:
parent
ac82c036d8
commit
5060262b79
4 changed files with 13 additions and 3 deletions
|
@ -35,7 +35,8 @@ let
|
|||
|
||||
# Match the default socket path for the Emacs version so emacsclient continues
|
||||
# to work without wrapping it.
|
||||
socketPath = "%t/emacs/server";
|
||||
socketDir = "%t/emacs";
|
||||
socketPath = "${socketDir}/server";
|
||||
|
||||
in {
|
||||
meta.maintainers = [ maintainers.tadfisher ];
|
||||
|
@ -112,6 +113,13 @@ in {
|
|||
SuccessExitStatus = 15;
|
||||
|
||||
Restart = "on-failure";
|
||||
} // optionalAttrs (cfg.socketActivation.enable) {
|
||||
# Use read-only directory permissions to prevent emacs from
|
||||
# deleting systemd's socket file before exiting.
|
||||
ExecStartPost =
|
||||
"${pkgs.coreutils}/bin/chmod --changes -w ${socketDir}";
|
||||
ExecStopPost =
|
||||
"${pkgs.coreutils}/bin/chmod --changes +w ${socketDir}";
|
||||
};
|
||||
} // optionalAttrs (!cfg.socketActivation.enable) {
|
||||
Install = { WantedBy = [ "default.target" ]; };
|
||||
|
|
|
@ -31,7 +31,7 @@ in {
|
|||
assertFileContent home-files/.config/systemd/user/emacs.service \
|
||||
${
|
||||
pkgs.substituteAll {
|
||||
inherit (pkgs) runtimeShell;
|
||||
inherit (pkgs) runtimeShell coreutils;
|
||||
src = ./emacs-socket-emacs.service;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ in {
|
|||
assertFileContent home-files/.config/systemd/user/emacs.service \
|
||||
${
|
||||
pkgs.substituteAll {
|
||||
inherit (pkgs) runtimeShell;
|
||||
inherit (pkgs) runtimeShell coreutils;
|
||||
src = ./emacs-socket-emacs.service;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
[Service]
|
||||
ExecStart=@runtimeShell@ -l -c "@emacs@/bin/emacs --fg-daemon='%t/emacs/server'"
|
||||
ExecStartPost=@coreutils@/bin/chmod --changes -w %t/emacs
|
||||
ExecStopPost=@coreutils@/bin/chmod --changes +w %t/emacs
|
||||
Restart=on-failure
|
||||
SuccessExitStatus=15
|
||||
Type=notify
|
||||
|
|
Loading…
Reference in a new issue