about summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorMauricio Collares <mauricio@collares.org>2020-12-28 01:12:44 -0300
committeradisbladis <adisbladis@gmail.com>2021-02-19 16:46:31 +0100
commitca4db1bc793e1534de7c6eb8fac3b2da53b3f27b (patch)
tree6475cee2612ad55c46ed870996c95d2adab45fb1 /pkgs/build-support
parent56923181e9535fe2c142d16ba1ee717762abdb53 (diff)
downloadnixlib-ca4db1bc793e1534de7c6eb8fac3b2da53b3f27b.tar
nixlib-ca4db1bc793e1534de7c6eb8fac3b2da53b3f27b.tar.gz
nixlib-ca4db1bc793e1534de7c6eb8fac3b2da53b3f27b.tar.bz2
nixlib-ca4db1bc793e1534de7c6eb8fac3b2da53b3f27b.tar.lz
nixlib-ca4db1bc793e1534de7c6eb8fac3b2da53b3f27b.tar.xz
nixlib-ca4db1bc793e1534de7c6eb8fac3b2da53b3f27b.tar.zst
nixlib-ca4db1bc793e1534de7c6eb8fac3b2da53b3f27b.zip
emacs: add currently compiling package dirs to load-path
Co-authored-by: Tad Fisher <tadfisher@gmail.com>
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/emacs/elpa.nix4
-rw-r--r--pkgs/build-support/emacs/emacs-funcs.sh (renamed from pkgs/build-support/emacs/setup-hook.sh)10
-rw-r--r--pkgs/build-support/emacs/generic.nix25
-rw-r--r--pkgs/build-support/emacs/melpa.nix4
4 files changed, 26 insertions, 17 deletions
diff --git a/pkgs/build-support/emacs/elpa.nix b/pkgs/build-support/emacs/elpa.nix
index 214aed9c3f9c..41a0670d0c84 100644
--- a/pkgs/build-support/emacs/elpa.nix
+++ b/pkgs/build-support/emacs/elpa.nix
@@ -1,6 +1,6 @@
 # builder for Emacs packages built for packages.el
 
-{ lib, stdenv, emacs, texinfo }:
+{ lib, stdenv, emacs, texinfo, writeText }:
 
 with lib;
 
@@ -19,7 +19,7 @@ let
 
 in
 
-import ./generic.nix { inherit lib stdenv emacs texinfo; } ({
+import ./generic.nix { inherit lib stdenv emacs texinfo writeText; } ({
 
   phases = "installPhase fixupPhase distPhase";
 
diff --git a/pkgs/build-support/emacs/setup-hook.sh b/pkgs/build-support/emacs/emacs-funcs.sh
index f6f2331b8e02..e1e6a3b62208 100644
--- a/pkgs/build-support/emacs/setup-hook.sh
+++ b/pkgs/build-support/emacs/emacs-funcs.sh
@@ -32,13 +32,3 @@ addEmacsVars () {
     fi
   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
diff --git a/pkgs/build-support/emacs/generic.nix b/pkgs/build-support/emacs/generic.nix
index d84fa24923df..1456d9e423d8 100644
--- a/pkgs/build-support/emacs/generic.nix
+++ b/pkgs/build-support/emacs/generic.nix
@@ -1,6 +1,6 @@
 # generic builder for Emacs packages
 
-{ lib, stdenv, emacs, texinfo, ... }:
+{ lib, stdenv, emacs, texinfo, writeText, ... }:
 
 with lib;
 
@@ -49,7 +49,19 @@ stdenv.mkDerivation ({
   propagatedBuildInputs = 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;
 
@@ -63,9 +75,16 @@ stdenv.mkDerivation ({
   addEmacsNativeLoadPath = true;
 
   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 \
       | 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"
   '';
 }
 
diff --git a/pkgs/build-support/emacs/melpa.nix b/pkgs/build-support/emacs/melpa.nix
index d6fe3085837e..824611b20c8a 100644
--- a/pkgs/build-support/emacs/melpa.nix
+++ b/pkgs/build-support/emacs/melpa.nix
@@ -1,7 +1,7 @@
 # builder for Emacs packages built for packages.el
 # using MELPA package-build.el
 
-{ lib, stdenv, fetchFromGitHub, emacs, texinfo }:
+{ lib, stdenv, fetchFromGitHub, emacs, texinfo, writeText }:
 
 with lib;
 
@@ -28,7 +28,7 @@ let
 
 in
 
-import ./generic.nix { inherit lib stdenv emacs texinfo; } ({
+import ./generic.nix { inherit lib stdenv emacs texinfo writeText; } ({
 
   ename =
     if ename == null