-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
emacs: allow wrapped emacs to execute itself again #361145
emacs: allow wrapped emacs to execute itself again #361145
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great at a first glance. I'll do a real review later.
Please target the staging
branch.
8a478a1
to
b344d66
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small problem: I cannot reproduce the restart-emacs
issue.
My steps are as follows:
nix build --include 'nixpkgs=flake:github:nixos/nixpkgs?rev=55d15ad12a74eb7d4646254e13638ad0c4128776' --impure --expr 'with (import <nixpkgs> { config = { }; overlays = [ ]; }); emacs.pkgs.withPackages (ps: [ ps.magit ])'
export PATH=$PWD/result/bin:$PATH
emacs --init-directory=$(mktemp -d)
- M-x restart-emacs RET
- M-x magit RET
There is no error in step 5, which means the restarted Emacs can find its packages.
fixes NixOS#145302 NixOS#237855 emacsWithPackages wrapper script/`site-start.el` sanitize EMACSLOADPATH, to make nested emacs invocations independent of the package set specified in emacsWithPackages. But there are valid use cases when one needs to call nested emacs with the same package set. This includes built-in emacs functionality such as async native compilations, and also external packages like `emacs-async` and `esup`. In all of these cases `invocation-directory`/`invocation-name` variables are being used to launch nested emacs. With this patch these variables will be populated to point to the emacsWithPackages wrapper executable, so that executing `(file-name-concat invocation-directory invocation-name)` will give a fully functional emacs again. `EMACSLOADPATH` sanitization was introduced by NixOS#106486, this behaviour stays unchanged. The reasoning was to be able to run different emacs executables without polluting their EMACSLOADPATH (as described here NixOS@23d4bfb). The only change is that invoking itself is again feasible (and that's what emacs actually expects). Co-authored-by: Lin Jian <[email protected]>
b344d66
to
5f9cbf9
Compare
I took the liberty to dealt with the suffix In addition, I re-targeted this PR to |
Yes, you are right - I've looked a bit into why |
fixes #145302 #237855
emacsWithPackages wrapper script/
site-start.el
sanitizes EMACSLOADPATH, to make nested emacs invocations independent of the package set specified in emacsWithPackages.But there are valid use cases when one needs to call nested emacs with the same package set. This includes built-in emacs functionality such as
restart-emacs
and async native compilation, and also external packages likeemacs-async
andesup
. In all of these casesinvocation-directory
/invocation-name
variables are being used to launch nested emacs.With this patch these variables will be populated to point to the emacsWithPackages wrapper executable, so that executing
(file-name-concat invocation-directory invocation-name)
will give a fully functional emacs again.EMACSLOADPATH
sanitization was introduced by #106486, this behaviour stays unchanged. The reasoning was to be able to run different emacs executables without polluting their EMACSLOADPATH (as described here 23d4bfb). The only change is that invoking itself is again feasible (and that's what emacs actually expects).Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.