mirror of
https://github.com/nix-community/home-manager
synced 2025-01-11 11:39:49 +01: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
|
# Match the default socket path for the Emacs version so emacsclient continues
|
||||||
# to work without wrapping it.
|
# to work without wrapping it.
|
||||||
socketPath = "%t/emacs/server";
|
socketDir = "%t/emacs";
|
||||||
|
socketPath = "${socketDir}/server";
|
||||||
|
|
||||||
in {
|
in {
|
||||||
meta.maintainers = [ maintainers.tadfisher ];
|
meta.maintainers = [ maintainers.tadfisher ];
|
||||||
|
@ -112,6 +113,13 @@ in {
|
||||||
SuccessExitStatus = 15;
|
SuccessExitStatus = 15;
|
||||||
|
|
||||||
Restart = "on-failure";
|
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) {
|
} // optionalAttrs (!cfg.socketActivation.enable) {
|
||||||
Install = { WantedBy = [ "default.target" ]; };
|
Install = { WantedBy = [ "default.target" ]; };
|
||||||
|
|
|
@ -31,7 +31,7 @@ in {
|
||||||
assertFileContent home-files/.config/systemd/user/emacs.service \
|
assertFileContent home-files/.config/systemd/user/emacs.service \
|
||||||
${
|
${
|
||||||
pkgs.substituteAll {
|
pkgs.substituteAll {
|
||||||
inherit (pkgs) runtimeShell;
|
inherit (pkgs) runtimeShell coreutils;
|
||||||
src = ./emacs-socket-emacs.service;
|
src = ./emacs-socket-emacs.service;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ in {
|
||||||
assertFileContent home-files/.config/systemd/user/emacs.service \
|
assertFileContent home-files/.config/systemd/user/emacs.service \
|
||||||
${
|
${
|
||||||
pkgs.substituteAll {
|
pkgs.substituteAll {
|
||||||
inherit (pkgs) runtimeShell;
|
inherit (pkgs) runtimeShell coreutils;
|
||||||
src = ./emacs-socket-emacs.service;
|
src = ./emacs-socket-emacs.service;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=@runtimeShell@ -l -c "@emacs@/bin/emacs --fg-daemon='%t/emacs/server'"
|
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
|
Restart=on-failure
|
||||||
SuccessExitStatus=15
|
SuccessExitStatus=15
|
||||||
Type=notify
|
Type=notify
|
||||||
|
|
Loading…
Reference in a new issue