diff --git a/pkgs/applications/editors/emacs/build-support/wrapper.nix b/pkgs/applications/editors/emacs/build-support/wrapper.nix index 5b325f5e0a9e69..2e5232684fe5b8 100644 --- a/pkgs/applications/editors/emacs/build-support/wrapper.nix +++ b/pkgs/applications/editors/emacs/build-support/wrapper.nix @@ -198,6 +198,8 @@ runCommand --subst-var-by bash ${emacs.stdenv.shell} \ --subst-var-by wrapperSiteLisp "$deps/share/emacs/site-lisp" \ --subst-var-by wrapperSiteLispNative "$deps/share/emacs/native-lisp" \ + --subst-var-by wrapperInvocationDirectory "$out/bin" \ + --subst-var-by wrapperInvocationName "$progname" \ --subst-var prog chmod +x $out/bin/$progname # Create a “NOP” binary wrapper for the pure sake of it becoming a @@ -222,6 +224,8 @@ runCommand --subst-var-by bash ${emacs.stdenv.shell} \ --subst-var-by wrapperSiteLisp "$deps/share/emacs/site-lisp" \ --subst-var-by wrapperSiteLispNative "$deps/share/emacs/native-lisp" \ + --subst-var-by wrapperInvocationDirectory "$out/Applications/Emacs.app/Contents/MacOS" \ + --subst-var-by wrapperInvocationName "Emacs" \ --subst-var-by prog "$emacs/Applications/Emacs.app/Contents/MacOS/Emacs" chmod +x $out/Applications/Emacs.app/Contents/MacOS/Emacs wrapProgramBinary $out/Applications/Emacs.app/Contents/MacOS/Emacs diff --git a/pkgs/applications/editors/emacs/build-support/wrapper.sh b/pkgs/applications/editors/emacs/build-support/wrapper.sh old mode 100644 new mode 100755 index 44762bd4582b0b..e83308bf5b3250 --- a/pkgs/applications/editors/emacs/build-support/wrapper.sh +++ b/pkgs/applications/editors/emacs/build-support/wrapper.sh @@ -50,4 +50,7 @@ export emacsWithPackages_siteLisp=@wrapperSiteLisp@ export EMACSNATIVELOADPATH="${newNativeLoadPath[*]}" export emacsWithPackages_siteLispNative=@wrapperSiteLispNative@ +export emacsWithPackages_invocationDirectory=@wrapperInvocationDirectory@ +export emacsWithPackages_invocationName=@wrapperInvocationName@ + exec @prog@ "$@" diff --git a/pkgs/applications/editors/emacs/site-start.el b/pkgs/applications/editors/emacs/site-start.el index c844e703e385fe..4fb65367bf806d 100644 --- a/pkgs/applications/editors/emacs/site-start.el +++ b/pkgs/applications/editors/emacs/site-start.el @@ -39,6 +39,16 @@ least specific (the system profile)" (setenv "EMACSNATIVELOADPATH" (when new-env-list (mapconcat 'identity new-env-list ":")))))) +(let ((wrapper-invocation-directory (getenv "emacsWithPackages_invocationDirectory"))) + (when wrapper-invocation-directory + (setq invocation-directory wrapper-invocation-directory) + (setenv "emacsWithPackages_invocationDirectory" nil))) + +(let ((wrapper-invocation-name (getenv "emacsWithPackages_invocationName"))) + (when wrapper-invocation-name + (setq invocation-name wrapper-invocation-name) + (setenv "emacsWithPackages_invocationName" nil))) + ;;; Set up native-comp load path. (when (featurep 'native-compile) ;; Append native-comp subdirectories from `NIX_PROFILES'.