emacs: fix service environment
Emacs populates 'exec-path' at launch from the 'PATH' environment variable. Likewise, the emacs derivation from nixpkgs populates 'load-path' from the 'NIX_PROFILES' variable. As neither of these are available by default in the systemd user manager, revert to the previous behavior of launching the Emacs daemon from a login shell. Fixes #1354 Fixes #1340 PR #1355
This commit is contained in:
parent
8f2342e13a
commit
54b69d2ef8
|
@ -97,13 +97,19 @@ in {
|
|||
};
|
||||
|
||||
Service = {
|
||||
ExecStart = "${emacsBinPath}/emacs --fg-daemon${
|
||||
# We wrap ExecStart in a login shell so Emacs starts with the user's
|
||||
# environment, most importantly $PATH and $NIX_PROFILES. It may be
|
||||
# worth investigating a more targeted approach for user services to
|
||||
# import the user environment.
|
||||
ExecStart = ''
|
||||
${pkgs.runtimeShell} -l -c "${emacsBinPath}/emacs --fg-daemon${
|
||||
# In case the user sets 'server-directory' or 'server-name' in
|
||||
# their Emacs config, we want to specify the socket path explicitly
|
||||
# so launching 'emacs.service' manually doesn't break emacsclient
|
||||
# when using socket activation.
|
||||
optionalString cfg.socketActivation.enable ''="${socketPath}"''
|
||||
}";
|
||||
optionalString cfg.socketActivation.enable
|
||||
"=${escapeShellArg socketPath}"
|
||||
}"'';
|
||||
# We use '(kill-emacs 0)' to avoid exiting with a failure code, which
|
||||
# would restart the service immediately.
|
||||
ExecStop = "${emacsBinPath}/emacsclient --eval '(kill-emacs 0)'";
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
WantedBy=default.target
|
||||
|
||||
[Service]
|
||||
ExecStart=@emacs@/bin/emacs --fg-daemon
|
||||
ExecStart=@runtimeShell@ -l -c "@emacs@/bin/emacs --fg-daemon"
|
||||
ExecStop=@emacs@/bin/emacsclient --eval '(kill-emacs 0)'
|
||||
Restart=on-failure
|
||||
|
||||
|
|
|
@ -24,7 +24,12 @@ with lib;
|
|||
assertFileExists home-path/share/applications/emacsclient.desktop
|
||||
|
||||
assertFileContent home-files/.config/systemd/user/emacs.service \
|
||||
${./emacs-service-emacs.service}
|
||||
${
|
||||
pkgs.substituteAll {
|
||||
inherit (pkgs) runtimeShell;
|
||||
src = ./emacs-service-emacs.service;
|
||||
}
|
||||
}
|
||||
assertFileContent home-path/share/applications/emacsclient.desktop \
|
||||
${./emacs-emacsclient.desktop}
|
||||
'';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[Service]
|
||||
ExecStart=@emacs@/bin/emacs --fg-daemon="%T/emacs%U/server"
|
||||
ExecStart=@runtimeShell@ -l -c "@emacs@/bin/emacs --fg-daemon='%T/emacs%U/server'"
|
||||
ExecStop=@emacs@/bin/emacsclient --eval '(kill-emacs 0)'
|
||||
Restart=on-failure
|
||||
|
||||
|
|
|
@ -27,7 +27,12 @@ with lib;
|
|||
assertFileContent home-files/.config/systemd/user/emacs.socket \
|
||||
${./emacs-socket-26-emacs.socket}
|
||||
assertFileContent home-files/.config/systemd/user/emacs.service \
|
||||
${./emacs-socket-26-emacs.service}
|
||||
${
|
||||
pkgs.substituteAll {
|
||||
inherit (pkgs) runtimeShell;
|
||||
src = ./emacs-socket-26-emacs.service;
|
||||
}
|
||||
}
|
||||
assertFileContent home-path/share/applications/emacsclient.desktop \
|
||||
${./emacs-emacsclient.desktop}
|
||||
'';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[Service]
|
||||
ExecStart=@emacs@/bin/emacs --fg-daemon="%t/emacs/server"
|
||||
ExecStart=@runtimeShell@ -l -c "@emacs@/bin/emacs --fg-daemon='%t/emacs/server'"
|
||||
ExecStop=@emacs@/bin/emacsclient --eval '(kill-emacs 0)'
|
||||
Restart=on-failure
|
||||
|
||||
|
|
|
@ -29,7 +29,12 @@ in {
|
|||
assertFileContent home-files/.config/systemd/user/emacs.socket \
|
||||
${./emacs-socket-27-emacs.socket}
|
||||
assertFileContent home-files/.config/systemd/user/emacs.service \
|
||||
${./emacs-socket-27-emacs.service}
|
||||
${
|
||||
pkgs.substituteAll {
|
||||
inherit (pkgs) runtimeShell;
|
||||
src = ./emacs-socket-27-emacs.service;
|
||||
}
|
||||
}
|
||||
assertFileContent home-path/share/applications/emacsclient.desktop \
|
||||
${./emacs-emacsclient.desktop}
|
||||
'';
|
||||
|
|
Loading…
Reference in a new issue