The first log in *Message* before this patch:
Loading /nix/store/bikm18vy6v07hmrvrll501i68440w9iw-emacs-29.1-rc1/share/emacs/site-lisp/site-start.el (source)...done
and after this patch:
Loading /nix/store/bikm18vy6v07hmrvrll501i68440w9iw-emacs-29.1-rc1/share/emacs/site-lisp/site-start (native compiled elisp)...done
This patch does two things:
1. making user profiles preferred over system profiles
2. putting sub dirs of one profile to the right place
- before this patch, they are appended to the end of load-path
- after this patch, they are inserted right after the profile
Example value of load-path before this patch:
/run/current-system/sw/share/emacs/site-lisp/
/etc/profiles/per-user/user/share/emacs/site-lisp/
/nix/store/hash1-emacs-packages-deps/share/emacs/site-lisp
/nix/store/hash1-emacs-packages-deps/share/emacs/site-lisp/elpa
/nix/store/hash1-emacs-packages-deps/share/emacs/site-lisp/elpa/wgrep-20230203.1214
/nix/store/hash2-emacs-29.1-rc1/share/emacs/29.1/site-lisp
/nix/store/hash2-emacs-29.1-rc1/share/emacs/site-lisp
/nix/store/hash2-emacs-29.1-rc1/share/emacs/29.1/lisp
/nix/store/hash2-emacs-29.1-rc1/share/emacs/29.1/lisp/vc
...
/etc/profiles/per-user/user/share/emacs/site-lisp/elpa
/etc/profiles/per-user/user/share/emacs/site-lisp/elpa/jinx-20230730.1200
/run/current-system/sw/share/emacs/site-lisp/elpa
/run/current-system/sw/share/emacs/site-lisp/elpa/repology-1.2.3
after this patch:
/etc/profiles/per-user/user/share/emacs/site-lisp
/etc/profiles/per-user/user/share/emacs/site-lisp/elpa
/etc/profiles/per-user/user/share/emacs/site-lisp/elpa/jinx-20230730.1200
/run/current-system/sw/share/emacs/site-lisp
/run/current-system/sw/share/emacs/site-lisp/elpa
/run/current-system/sw/share/emacs/site-lisp/elpa/repology-1.2.3
/nix/store/hash1-emacs-packages-deps/share/emacs/site-lisp
/nix/store/hash1-emacs-packages-deps/share/emacs/site-lisp/elpa
/nix/store/hash1-emacs-packages-deps/share/emacs/site-lisp/elpa/wgrep-20230203.1214
/nix/store/hash2-emacs-29.1-rc1/share/emacs/29.1/site-lisp
/nix/store/hash2-emacs-29.1-rc1/share/emacs/site-lisp
/nix/store/hash2-emacs-29.1-rc1/share/emacs/29.1/lisp
/nix/store/hash2-emacs-29.1-rc1/share/emacs/29.1/lisp/vc
...
I see no reason to symlink this dir.
Doing so may shadow unwanted libraries since the site-start.el of
Emacs adds paths under NIX_PROFILES to load-path.
It is added in [1] to fix "building emacs". However, I have no issue
in building and using Emacs after removing it.
[1]: https://github.com/NixOS/nixpkgs/pull/89351
"$out/share/emacs/site-lisp" is added to load-path in wrapper.sh[1]
using EMACSLOADPATH and "$out/share/emacs/native-lisp/" is added to
native-comp-eln-load-path in wrapper.sh[2] using
EMACSNATIVELOADPATH. There is no point to add them again here.
Additionally, the trailing "/" in "$out/share/emacs/native-lisp/"
causes duplicate entries in native-comp-eln-load-path:
("/nix/store/hash1-emacs-packages-deps/share/emacs/native-lisp/" ; [3]
"/home/user/.emacs.d/eln-cache/"
"/nix/store/hash1-emacs-packages-deps/share/emacs/native-lisp" ; [2]
"/nix/store/hash2-emacs-29.1-rc1/lib/emacs/29.1/native-lisp/")
load-path does not change with this patch applied.
[1]: 1476c13422/pkgs/build-support/emacs/wrapper.sh (L47)
[2]: 1476c13422/pkgs/build-support/emacs/wrapper.sh (L50)
[3]: 1476c13422/pkgs/build-support/emacs/wrapper.nix (L166)