emacs: Add comp-eln-load-path infrastructure
This commit is contained in:
@@ -34,7 +34,15 @@ in customEmacsPackages.emacsWithPackages (epkgs: [ epkgs.evil epkgs.magit ])
|
||||
|
||||
{ lib, lndir, makeWrapper, runCommand }: self:
|
||||
|
||||
with lib; let inherit (self) emacs; in
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
inherit (self) emacs;
|
||||
|
||||
nativeComp = emacs.nativeComp or false;
|
||||
|
||||
in
|
||||
|
||||
packagesFun: # packages explicitly requested by the user
|
||||
|
||||
@@ -95,6 +103,9 @@ runCommand
|
||||
}
|
||||
mkdir -p $out/bin
|
||||
mkdir -p $out/share/emacs/site-lisp
|
||||
${optionalString emacs.nativeComp ''
|
||||
mkdir -p $out/share/emacs/native-lisp
|
||||
''}
|
||||
|
||||
local requires
|
||||
for pkg in $explicitRequires; do
|
||||
@@ -116,6 +127,9 @@ runCommand
|
||||
linkEmacsPackage() {
|
||||
linkPath "$1" "bin" "bin"
|
||||
linkPath "$1" "share/emacs/site-lisp" "share/emacs/site-lisp"
|
||||
${optionalString nativeComp ''
|
||||
linkPath "$1" "share/emacs/native-lisp" "share/emacs/native-lisp"
|
||||
''}
|
||||
}
|
||||
|
||||
# Iterate over the array of inputs (avoiding nix's own interpolation)
|
||||
@@ -138,12 +152,21 @@ runCommand
|
||||
(load-file "$emacs/share/emacs/site-lisp/site-start.el")
|
||||
(add-to-list 'load-path "$out/share/emacs/site-lisp")
|
||||
(add-to-list 'exec-path "$out/bin")
|
||||
${optionalString nativeComp ''
|
||||
(add-to-list 'comp-eln-load-path "$out/share/emacs/native-lisp/")
|
||||
''}
|
||||
EOF
|
||||
# Link subdirs.el from the emacs distribution
|
||||
ln -s $emacs/share/emacs/site-lisp/subdirs.el -T $subdirs
|
||||
|
||||
# Byte-compiling improves start-up time only slightly, but costs nothing.
|
||||
$emacs/bin/emacs --batch -f batch-byte-compile "$siteStart" "$subdirs"
|
||||
|
||||
${optionalString nativeComp ''
|
||||
$emacs/bin/emacs --batch \
|
||||
--eval "(add-to-list 'comp-eln-load-path \"$out/share/emacs/native-lisp/\")" \
|
||||
-f batch-native-compile "$siteStart" "$subdirs"
|
||||
''}
|
||||
'';
|
||||
|
||||
inherit (emacs) meta;
|
||||
@@ -159,8 +182,14 @@ runCommand
|
||||
substitute ${./wrapper.sh} $out/bin/$progname \
|
||||
--subst-var-by bash ${emacs.stdenv.shell} \
|
||||
--subst-var-by wrapperSiteLisp "$deps/share/emacs/site-lisp" \
|
||||
--subst-var-by wrapperSiteLispNative "$deps/share/emacs/native-lisp:" \
|
||||
--subst-var prog
|
||||
chmod +x $out/bin/$progname
|
||||
|
||||
makeWrapper "$prog" "$out/bin/$progname" \
|
||||
--suffix EMACSLOADPATH ":" "$deps/share/emacs/site-lisp:" \
|
||||
--suffix EMACSNATIVELOADPATH ":" "$deps/share/emacs/native-lisp:"
|
||||
|
||||
done
|
||||
|
||||
# Wrap MacOS app
|
||||
@@ -173,11 +202,16 @@ runCommand
|
||||
$emacs/Applications/Emacs.app/Contents/Resources \
|
||||
$out/Applications/Emacs.app/Contents
|
||||
|
||||
|
||||
substitute ${./wrapper.sh} $out/Applications/Emacs.app/Contents/MacOS/Emacs \
|
||||
--subst-var-by bash ${emacs.stdenv.shell} \
|
||||
--subst-var-by wrapperSiteLisp "$deps/share/emacs/site-lisp" \
|
||||
--subst-var-by prog "$emacs/Applications/Emacs.app/Contents/MacOS/Emacs"
|
||||
chmod +x $out/Applications/Emacs.app/Contents/MacOS/Emacs
|
||||
|
||||
makeWrapper $emacs/Applications/Emacs.app/Contents/MacOS/Emacs $out/Applications/Emacs.app/Contents/MacOS/Emacs \
|
||||
--suffix EMACSLOADPATH ":" "$deps/share/emacs/site-lisp:" \
|
||||
--suffix EMACSNATIVELOADPATH ":" "$deps/share/emacs/native-lisp:"
|
||||
fi
|
||||
|
||||
mkdir -p $out/share
|
||||
|
||||
Reference in New Issue
Block a user