···1# generic builder for Emacs packages
23+{ lib, stdenv, emacs, texinfo, writeText, ... }:
45with lib;
6···49 propagatedBuildInputs = packageRequires;
50 propagatedUserEnvPkgs = packageRequires;
5152+ 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+ '';
6566 doCheck = false;
67···75 addEmacsNativeLoadPath = true;
7677 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+85 find $out/share/emacs -type f -name '*.el' -print0 \
86 | xargs -0 -n 1 -I {} -P $NIX_BUILD_CORES sh -c \
87+ "emacs --batch -f batch-native-compile {} || true"
88 '';
89}
90
+2-2
pkgs/build-support/emacs/melpa.nix
···1# builder for Emacs packages built for packages.el
2# using MELPA package-build.el
34-{ lib, stdenv, fetchFromGitHub, emacs, texinfo }:
56with lib;
7···2829in
3031-import ./generic.nix { inherit lib stdenv emacs texinfo; } ({
3233 ename =
34 if ename == null
···1# builder for Emacs packages built for packages.el
2# using MELPA package-build.el
34+{ lib, stdenv, fetchFromGitHub, emacs, texinfo, writeText }:
56with lib;
7···2829in
3031+import ./generic.nix { inherit lib stdenv emacs texinfo writeText; } ({
3233 ename =
34 if ename == null
···32 fi
33 done
34}
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