The hook is used to construct EMACSLOADPATH and EMACSNATIVELOADPATH from elisp packages in buildInputs for emacs in nativeBuildInputs to use during the build of an elisp package. Emacs is the right place to set this hook, which is similar to the fact that cc-wrapper[1] is the right place to set a hook[2] constructing NIX_CFLAGS_COMPILE. [1]: https://github.com/NixOS/nixpkgs/blob/17bfa4436fdbee1374b1797c8a9ddc8a3570cf51/pkgs/build-support/cc-wrapper/default.nix#L461 [2]: https://github.com/NixOS/nixpkgs/blob/17bfa4436fdbee1374b1797c8a9ddc8a3570cf51/pkgs/build-support/cc-wrapper/setup-hook.sh#L86
26 lines
750 B
Bash
26 lines
750 B
Bash
addToEmacsLoadPath() {
|
|
local lispDir="$1"
|
|
if [[ -d $lispDir && ${EMACSLOADPATH-} != *"$lispDir":* ]] ; then
|
|
# It turns out, that the trailing : is actually required
|
|
# see https://www.gnu.org/software/emacs/manual/html_node/elisp/Library-Search.html
|
|
export EMACSLOADPATH="$lispDir:${EMACSLOADPATH-}"
|
|
fi
|
|
}
|
|
|
|
addToEmacsNativeLoadPath() {
|
|
local nativeDir="$1"
|
|
if [[ -d $nativeDir && ${EMACSNATIVELOADPATH-} != *"$nativeDir":* ]]; then
|
|
export EMACSNATIVELOADPATH="$nativeDir:${EMACSNATIVELOADPATH-}"
|
|
fi
|
|
}
|
|
|
|
addEmacsVars () {
|
|
addToEmacsLoadPath "$1/share/emacs/site-lisp"
|
|
|
|
if [ -n "${addEmacsNativeLoadPath:-}" ]; then
|
|
addToEmacsNativeLoadPath "$1/share/emacs/native-lisp"
|
|
fi
|
|
}
|
|
|
|
addEnvHooks "$targetOffset" addEmacsVars
|