diff options
author | Tad Fisher <tadfisher@gmail.com> | 2020-06-23 17:17:33 -0700 |
---|---|---|
committer | Robert Helgesson <robert@rycee.net> | 2020-06-24 22:50:30 +0200 |
commit | 54b69d2ef868783533ce9c581cab7f0252b37149 (patch) | |
tree | 0842a082025f4e1f2f040f701edcc2c6584a7813 /modules/services/emacs.nix | |
parent | 8f2342e13a2ddc84ed5053e2bfc393184258c686 (diff) |
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
Diffstat (limited to 'modules/services/emacs.nix')
-rw-r--r-- | modules/services/emacs.nix | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/modules/services/emacs.nix b/modules/services/emacs.nix index 70c8d0d7041..a73b750c513 100644 --- a/modules/services/emacs.nix +++ b/modules/services/emacs.nix @@ -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)'"; |