emacs: add currently compiling package dirs to load-path

Co-authored-by: Tad Fisher <tadfisher@gmail.com>
This commit is contained in:
Mauricio Collares 2020-12-28 01:12:44 -03:00 committed by adisbladis
parent 56923181e9
commit ca4db1bc79
No known key found for this signature in database
GPG Key ID: 110BFAD44C6249B7
6 changed files with 29 additions and 20 deletions

View File

@ -20,7 +20,7 @@ instantenous and formats commits for you.
*/ */
{ lib, stdenv, texinfo }: { lib, stdenv, texinfo, writeText }:
self: let self: let
@ -31,7 +31,7 @@ self: let
}; };
elpaBuild = import ../../../build-support/emacs/elpa.nix { elpaBuild = import ../../../build-support/emacs/elpa.nix {
inherit lib stdenv texinfo; inherit lib stdenv texinfo writeText;
inherit (self) emacs; inherit (self) emacs;
}; };

View File

@ -1,6 +1,6 @@
# builder for Emacs packages built for packages.el # builder for Emacs packages built for packages.el
{ lib, stdenv, emacs, texinfo }: { lib, stdenv, emacs, texinfo, writeText }:
with lib; with lib;
@ -19,7 +19,7 @@ let
in in
import ./generic.nix { inherit lib stdenv emacs texinfo; } ({ import ./generic.nix { inherit lib stdenv emacs texinfo writeText; } ({
phases = "installPhase fixupPhase distPhase"; phases = "installPhase fixupPhase distPhase";

View File

@ -32,13 +32,3 @@ addEmacsVars () {
fi fi
done done
} }
if [[ ! -v emacsHookDone ]]; then
emacsHookDone=1
# If this is for a wrapper derivation, emacs and the dependencies are all
# run-time dependencies. If this is for precompiling packages into bytecode,
# emacs is a compile-time dependency of the package.
addEnvHooks "$hostOffset" addEmacsVars
addEnvHooks "$targetOffset" addEmacsVars
fi

View File

@ -1,6 +1,6 @@
# generic builder for Emacs packages # generic builder for Emacs packages
{ lib, stdenv, emacs, texinfo, ... }: { lib, stdenv, emacs, texinfo, writeText, ... }:
with lib; with lib;
@ -49,7 +49,19 @@ stdenv.mkDerivation ({
propagatedBuildInputs = packageRequires; propagatedBuildInputs = packageRequires;
propagatedUserEnvPkgs = packageRequires; propagatedUserEnvPkgs = packageRequires;
setupHook = ./setup-hook.sh; setupHook = writeText "setup-hook.sh" ''
source ${./emacs-funcs.sh}
if [[ ! -v emacsHookDone ]]; then
emacsHookDone=1
# If this is for a wrapper derivation, emacs and the dependencies are all
# run-time dependencies. If this is for precompiling packages into bytecode,
# emacs is a compile-time dependency of the package.
addEnvHooks "$hostOffset" addEmacsVars
addEnvHooks "$targetOffset" addEmacsVars
fi
'';
doCheck = false; doCheck = false;
@ -63,9 +75,16 @@ stdenv.mkDerivation ({
addEmacsNativeLoadPath = true; addEmacsNativeLoadPath = true;
postInstall = '' postInstall = ''
# Besides adding the output directory to the native load path, make sure
# the current package's elisp files are in the load path, otherwise
# (require 'file-b) from file-a.el in the same package will fail.
mkdir -p $out/share/emacs/native-lisp
source ${./emacs-funcs.sh}
addEmacsVars "$out"
find $out/share/emacs -type f -name '*.el' -print0 \ find $out/share/emacs -type f -name '*.el' -print0 \
| xargs -0 -n 1 -I {} -P $NIX_BUILD_CORES sh -c \ | xargs -0 -n 1 -I {} -P $NIX_BUILD_CORES sh -c \
"emacs --batch --eval=\"(add-to-list 'comp-eln-load-path \\\"$out/share/emacs/native-lisp/\\\")\" -f batch-native-compile {} || true" "emacs --batch -f batch-native-compile {} || true"
''; '';
} }

View File

@ -1,7 +1,7 @@
# builder for Emacs packages built for packages.el # builder for Emacs packages built for packages.el
# using MELPA package-build.el # using MELPA package-build.el
{ lib, stdenv, fetchFromGitHub, emacs, texinfo }: { lib, stdenv, fetchFromGitHub, emacs, texinfo, writeText }:
with lib; with lib;
@ -28,7 +28,7 @@ let
in in
import ./generic.nix { inherit lib stdenv emacs texinfo; } ({ import ./generic.nix { inherit lib stdenv emacs texinfo writeText; } ({
ename = ename =
if ename == null if ename == null

View File

@ -45,7 +45,7 @@
let let
mkElpaPackages = import ../applications/editors/emacs-modes/elpa-packages.nix { mkElpaPackages = import ../applications/editors/emacs-modes/elpa-packages.nix {
inherit lib stdenv texinfo; inherit lib stdenv texinfo writeText;
}; };
# Contains both melpa stable & unstable # Contains both melpa stable & unstable