From 7bd6dfde2feeb6d8472eb36f87c549b791665e38 Mon Sep 17 00:00:00 2001 From: ncaq Date: Tue, 12 May 2026 12:24:28 +0900 Subject: [PATCH] emacs/wrapper.nix: expose extra package binaries via PATH The withPackages wrapper aggregates extraEmacsPackages binaries under emacs-packages-deps/bin. That directory is added to exec-path but the PATH environment variable is left untouched. Tools that rebuild process-environment from PATH (notably direnv/envrc) lose access to them. Mirror the existing exec-path entry into PATH from the generated `site-start.el` file. This makes subprocess environment reconstruction see those binaries. Refs: https://github.com/purcell/envrc/issues/9 --- pkgs/applications/editors/emacs/build-support/wrapper.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgs/applications/editors/emacs/build-support/wrapper.nix b/pkgs/applications/editors/emacs/build-support/wrapper.nix index 8a36c507afff..694eaf512395 100644 --- a/pkgs/applications/editors/emacs/build-support/wrapper.nix +++ b/pkgs/applications/editors/emacs/build-support/wrapper.nix @@ -180,6 +180,13 @@ runCommand (lib.appendToName "with-packages" emacs).name ;; "$out/share/emacs/site-lisp" is added to load-path in wrapper.sh ;; "$out/share/emacs/native-lisp" is added to native-comp-eln-load-path in wrapper.sh (add-to-list 'exec-path "$out/bin") + ;; Also expose extra package binaries via PATH so that subprocesses + ;; which rebuild their environment from PATH (e.g. direnv/envrc) can + ;; still find them. See https://github.com/purcell/envrc/issues/9 + (let ((deps-bin "$out/bin") + (current-path (or (getenv "PATH") ""))) + (unless (member deps-bin (split-string current-path path-separator)) + (setenv "PATH" (concat deps-bin path-separator current-path)))) ${lib.optionalString withTreeSitter '' (add-to-list 'treesit-extra-load-path "$out/lib/") ''}