restart-emacs icon indicating copy to clipboard operation
restart-emacs copied to clipboard

Doesn't work with Nix

Open nosewings opened this issue 2 years ago • 1 comments

When running an Emacs built with emacsWithPackages from Nix, restart-emacs picks the wrong Emacs binary to start.

emacsWithPackages creates a wrapper script that sets up the Emacs load path before running the Emacs binary. So what ends up happening is that restart-emacs executes the Emacs binary (obtained via invocation-directory), but without the load-path set properly.

The easiest solution I can see would be to allow the user to configure the command used to start a new Emacs instance.

nosewings avatar Jun 20 '22 21:06 nosewings

For what it's worth, I was able to get this working with something like the following:

(defun nosewings/restart-emacs-advice (function &rest args)
  (let ((invocation-directory "~/.nix-profile/bin/"))
    (apply function args)))
(advice-add #'restart-emacs :around #'nosewings/restart-emacs-advice)

However, this relies on the implementation detail that restart-emacs uses invocation-directory.

nosewings avatar Jun 25 '22 23:06 nosewings