diff --git a/pkgs/applications/editors/emacs/build-support/emacs-funcs.sh b/pkgs/applications/editors/emacs/build-support/emacs-funcs.sh index e1e6a3b62208..b6b2a3bd374d 100644 --- a/pkgs/applications/editors/emacs/build-support/emacs-funcs.sh +++ b/pkgs/applications/editors/emacs/build-support/emacs-funcs.sh @@ -20,15 +20,4 @@ addEmacsVars () { if [ -n "${addEmacsNativeLoadPath:-}" ]; then addToEmacsNativeLoadPath "$1/share/emacs/native-lisp" fi - - # Add sub paths to the Emacs load path if it is a directory - # containing .el files. This is necessary to build some packages, - # e.g., using trivialBuild. - for lispDir in \ - "$1/share/emacs/site-lisp/"* \ - "$1/share/emacs/site-lisp/elpa/"*; do - if [[ -d $lispDir && "$(echo "$lispDir"/*.el)" ]] ; then - addToEmacsLoadPath "$lispDir" - fi - done } diff --git a/pkgs/applications/editors/emacs/build-support/generic.nix b/pkgs/applications/editors/emacs/build-support/generic.nix index 9f1b2308cc43..b032b587b798 100644 --- a/pkgs/applications/editors/emacs/build-support/generic.nix +++ b/pkgs/applications/editors/emacs/build-support/generic.nix @@ -86,10 +86,14 @@ libBuildHelper.extendMkDerivation' stdenv.mkDerivation (finalAttrs: source ${./emacs-funcs.sh} addEmacsVars "$out" + # package-activate-all is used to activate packages. In other builder + # helpers, package-initialize is used for this purpose because + # package-activate-all is not available before Emacs 27. find $out/share/emacs -type f -name '*.el' -not -name ".dir-locals.el" -print0 \ | xargs --verbose -0 -I {} -n 1 -P $NIX_BUILD_CORES sh -c \ "emacs \ --batch \ + -f package-activate-all \ --eval '(setq native-comp-eln-load-path (cdr native-comp-eln-load-path))' \ --eval '(setq large-file-warning-threshold nil)' \ --eval '(setq byte-compile-error-on-warn ${if finalAttrs.turnCompilationWarningToError then "t" else "nil"})' \ diff --git a/pkgs/applications/editors/emacs/build-support/trivial.nix b/pkgs/applications/editors/emacs/build-support/trivial.nix index 8c515363f427..2e4da1ca8ea0 100644 --- a/pkgs/applications/editors/emacs/build-support/trivial.nix +++ b/pkgs/applications/editors/emacs/build-support/trivial.nix @@ -19,7 +19,7 @@ args: foundMakefile=1 fi - emacs -L . --batch -f batch-byte-compile *.el + emacs -l package -f package-initialize -L . --batch -f batch-byte-compile *.el runHook postBuild '';