git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #107777 from collares/native-load-path

emacs: add currently compiling package dirs to load-path

commit44864cd2efcce00eea1ee36f7265ab0b7d74f8a2 authoradisbladis <adisbladis@gmail.com> dateFri 19 Feb 2021, 17:59 (6 years ago) parentcad32a9ca4db1b
6 files changed+29−20
pkgs/applications/editors/emacs-modes/elpa-packages.nix+2−2 pkgs/build-support/emacs/elpa.nix+2−2 pkgs/build-support/emacs/setup-hook.sh → pkgs/build-support/emacs/emacs-funcs.sh−10 pkgs/build-support/emacs/generic.nix+22−3 pkgs/build-support/emacs/melpa.nix+2−2 pkgs/top-level/emacs-packages.nix+1−1
pkgs/applications/editors/emacs-modes/elpa-packages.nix+2−2
@@ -20,7 +20,7 @@ instantenous and formats commits for you.
2020
2121*/
2222
23−{ lib, stdenv, texinfo }:
23+{ lib, stdenv, texinfo, writeText }:
2424
2525self: let
2626
@@ -31,7 +31,7 @@ self: let
3131 };
3232
3333 elpaBuild = import ../../../build-support/emacs/elpa.nix {
34− inherit lib stdenv texinfo;
34+ inherit lib stdenv texinfo writeText;
3535 inherit (self) emacs;
3636 };
3737
pkgs/build-support/emacs/elpa.nix+2−2
@@ -1,6 +1,6 @@
11# builder for Emacs packages built for packages.el
22
3−{ lib, stdenv, emacs, texinfo }:
3+{ lib, stdenv, emacs, texinfo, writeText }:
44
55with lib;
66
@@ -19,7 +19,7 @@ let
1919
2020in
2121
22−import ./generic.nix { inherit lib stdenv emacs texinfo; } ({
22+import ./generic.nix { inherit lib stdenv emacs texinfo writeText; } ({
2323
2424 phases = "installPhase fixupPhase distPhase";
2525
pkgs/build-support/emacs/setup-hook.sh → pkgs/build-support/emacs/emacs-funcs.shrenamed−10
@@ -32,13 +32,3 @@ addEmacsVars () {
3232 fi
3333 done
3434}
35−
36−if [[ ! -v emacsHookDone ]]; then
37− emacsHookDone=1
38−
39− # If this is for a wrapper derivation, emacs and the dependencies are all
40− # run-time dependencies. If this is for precompiling packages into bytecode,
41− # emacs is a compile-time dependency of the package.
42− addEnvHooks "$hostOffset" addEmacsVars
43− addEnvHooks "$targetOffset" addEmacsVars
44−fi
pkgs/build-support/emacs/generic.nix+22−3
@@ -1,6 +1,6 @@
11# generic builder for Emacs packages
22
3−{ lib, stdenv, emacs, texinfo, ... }:
3+{ lib, stdenv, emacs, texinfo, writeText, ... }:
44
55with lib;
66
@@ -49,7 +49,19 @@ stdenv.mkDerivation ({
4949 propagatedBuildInputs = packageRequires;
5050 propagatedUserEnvPkgs = packageRequires;
5151
52− setupHook = ./setup-hook.sh;
52+ setupHook = writeText "setup-hook.sh" ''
53+ source ${./emacs-funcs.sh}
54+
55+ if [[ ! -v emacsHookDone ]]; then
56+ emacsHookDone=1
57+
58+ # If this is for a wrapper derivation, emacs and the dependencies are all
59+ # run-time dependencies. If this is for precompiling packages into bytecode,
60+ # emacs is a compile-time dependency of the package.
61+ addEnvHooks "$hostOffset" addEmacsVars
62+ addEnvHooks "$targetOffset" addEmacsVars
63+ fi
64+ '';
5365
5466 doCheck = false;
5567
@@ -63,9 +75,16 @@ stdenv.mkDerivation ({
6375 addEmacsNativeLoadPath = true;
6476
6577 postInstall = ''
78+ # Besides adding the output directory to the native load path, make sure
79+ # the current package's elisp files are in the load path, otherwise
80+ # (require 'file-b) from file-a.el in the same package will fail.
81+ mkdir -p $out/share/emacs/native-lisp
82+ source ${./emacs-funcs.sh}
83+ addEmacsVars "$out"
84+
6685 find $out/share/emacs -type f -name '*.el' -print0 \
6786 | xargs -0 -n 1 -I {} -P $NIX_BUILD_CORES sh -c \
68− "emacs --batch --eval=\"(add-to-list 'comp-eln-load-path \\\"$out/share/emacs/native-lisp/\\\")\" -f batch-native-compile {} || true"
87+ "emacs --batch -f batch-native-compile {} || true"
6988 '';
7089}
7190
pkgs/build-support/emacs/melpa.nix+2−2
@@ -1,7 +1,7 @@
11# builder for Emacs packages built for packages.el
22# using MELPA package-build.el
33
4−{ lib, stdenv, fetchFromGitHub, emacs, texinfo }:
4+{ lib, stdenv, fetchFromGitHub, emacs, texinfo, writeText }:
55
66with lib;
77
@@ -28,7 +28,7 @@ let
2828
2929in
3030
31−import ./generic.nix { inherit lib stdenv emacs texinfo; } ({
31+import ./generic.nix { inherit lib stdenv emacs texinfo writeText; } ({
3232
3333 ename =
3434 if ename == null
pkgs/top-level/emacs-packages.nix+1−1
@@ -45,7 +45,7 @@
4545let
4646
4747 mkElpaPackages = import ../applications/editors/emacs-modes/elpa-packages.nix {
48− inherit lib stdenv texinfo;
48+ inherit lib stdenv texinfo writeText;
4949 };
5050
5151 # Contains both melpa stable & unstable