emacs: Add comp-eln-load-path infrastructure
This commit is contained in:
parent
84bc4d25fe
commit
a7cb8e36ac
@ -42,7 +42,12 @@ assert withXwidgets -> withGTK3 && webkitgtk != null;
|
|||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
in stdenv.mkDerivation {
|
in stdenv.mkDerivation (lib.optionalAttrs nativeComp {
|
||||||
|
NATIVE_FULL_AOT = "1";
|
||||||
|
LIBRARY_PATH = "${lib.getLib stdenv.cc.libc}/lib";
|
||||||
|
} // lib.optionalAttrs stdenv.isDarwin {
|
||||||
|
CFLAGS = "-DMAC_OS_X_VERSION_MAX_ALLOWED=101200";
|
||||||
|
} // {
|
||||||
inherit pname version patches;
|
inherit pname version patches;
|
||||||
|
|
||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
@ -88,10 +93,6 @@ in stdenv.mkDerivation {
|
|||||||
""
|
""
|
||||||
];
|
];
|
||||||
|
|
||||||
CFLAGS = "-DMAC_OS_X_VERSION_MAX_ALLOWED=101200";
|
|
||||||
|
|
||||||
LIBRARY_PATH = if nativeComp then "${lib.getLib stdenv.cc.libc}/lib" else "";
|
|
||||||
|
|
||||||
nativeBuildInputs = [ pkgconfig makeWrapper ]
|
nativeBuildInputs = [ pkgconfig makeWrapper ]
|
||||||
++ lib.optionals srcRepo [ autoreconfHook texinfo ]
|
++ lib.optionals srcRepo [ autoreconfHook texinfo ]
|
||||||
++ lib.optional (withX && (withGTK3 || withXwidgets)) wrapGAppsHook;
|
++ lib.optional (withX && (withGTK3 || withXwidgets)) wrapGAppsHook;
|
||||||
@ -155,6 +156,11 @@ in stdenv.mkDerivation {
|
|||||||
mv nextstep/Emacs.app $out/Applications
|
mv nextstep/Emacs.app $out/Applications
|
||||||
'' + lib.optionalString (nativeComp && withNS) ''
|
'' + lib.optionalString (nativeComp && withNS) ''
|
||||||
ln -snf $out/lib/emacs/*/native-lisp $out/Applications/Emacs.app/Contents/native-lisp
|
ln -snf $out/lib/emacs/*/native-lisp $out/Applications/Emacs.app/Contents/native-lisp
|
||||||
|
'' + lib.optionalString nativeComp ''
|
||||||
|
mkdir -p $out/share/emacs/native-lisp
|
||||||
|
$out/bin/emacs --batch \
|
||||||
|
--eval "(add-to-list 'comp-eln-load-path \"$out/share/emacs/native-lisp\")" \
|
||||||
|
-f batch-native-compile $out/share/emacs/site-lisp/site-start.el
|
||||||
'';
|
'';
|
||||||
|
|
||||||
postFixup = lib.concatStringsSep "\n" [
|
postFixup = lib.concatStringsSep "\n" [
|
||||||
@ -195,4 +201,4 @@ in stdenv.mkDerivation {
|
|||||||
separately.
|
separately.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
})
|
||||||
|
@ -34,6 +34,25 @@ least specific (the system profile)"
|
|||||||
(setenv "EMACSLOADPATH" (when new-env-list
|
(setenv "EMACSLOADPATH" (when new-env-list
|
||||||
(mapconcat 'identity new-env-list ":"))))))
|
(mapconcat 'identity new-env-list ":"))))))
|
||||||
|
|
||||||
|
(let ((wrapper-site-lisp (getenv "emacsWithPackages_siteLispNative"))
|
||||||
|
(env-load-path (getenv "EMACSNATIVELOADPATH")))
|
||||||
|
(when wrapper-site-lisp
|
||||||
|
(setenv "emacsWithPackages_siteLispNative" nil))
|
||||||
|
(when (and wrapper-site-lisp env-load-path)
|
||||||
|
(let* ((env-list (split-string env-load-path ":"))
|
||||||
|
(new-env-list (delete wrapper-site-lisp env-list)))
|
||||||
|
(setenv "EMACSNATIVELOADPATH" (when new-env-list
|
||||||
|
(mapconcat 'identity new-env-list ":"))))))
|
||||||
|
|
||||||
|
;;; Set up native-comp load path.
|
||||||
|
(when (featurep 'comp)
|
||||||
|
;; Append native-comp subdirectories from `NIX_PROFILES'.
|
||||||
|
(setq comp-eln-load-path
|
||||||
|
(append (mapcar (lambda (profile-dir)
|
||||||
|
(concat profile-dir "/share/emacs/native-lisp/"))
|
||||||
|
(nix--profile-paths))
|
||||||
|
comp-eln-load-path)))
|
||||||
|
|
||||||
;;; Make `woman' find the man pages
|
;;; Make `woman' find the man pages
|
||||||
(defvar woman-manpath)
|
(defvar woman-manpath)
|
||||||
(eval-after-load 'woman
|
(eval-after-load 'woman
|
||||||
|
@ -60,10 +60,13 @@ stdenv.mkDerivation ({
|
|||||||
|
|
||||||
LIBRARY_PATH = "${lib.getLib stdenv.cc.libc}/lib";
|
LIBRARY_PATH = "${lib.getLib stdenv.cc.libc}/lib";
|
||||||
|
|
||||||
postInstall = ''
|
addEmacsNativeLoadPath = true;
|
||||||
find $out/share/emacs -type f -name '*.el' -print0 | xargs -0 -n 1 -I {} -P $NIX_BUILD_CORES sh -c "emacs --batch -f batch-native-compile {} || true"
|
|
||||||
'';
|
|
||||||
|
|
||||||
|
postInstall = ''
|
||||||
|
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"
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
|
||||||
// removeAttrs args [ "buildInputs" "packageRequires"
|
// removeAttrs args [ "buildInputs" "packageRequires"
|
||||||
|
@ -7,9 +7,20 @@ addToEmacsLoadPath() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addToEmacsNativeLoadPath() {
|
||||||
|
local nativeDir="$1"
|
||||||
|
if [[ -d $nativeDir && ${EMACSNATIVELOADPATH-} != *"$nativeDir":* ]]; then
|
||||||
|
export EMACSNATIVELOADPATH="$nativeDir:${EMACSNATIVELOADPATH-}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
addEmacsVars () {
|
addEmacsVars () {
|
||||||
addToEmacsLoadPath "$1/share/emacs/site-lisp"
|
addToEmacsLoadPath "$1/share/emacs/site-lisp"
|
||||||
|
|
||||||
|
if [ -n "${addEmacsNativeLoadPath:-}" ]; then
|
||||||
|
addToEmacsNativeLoadPath "$1/share/emacs/native-lisp"
|
||||||
|
fi
|
||||||
|
|
||||||
# Add sub paths to the Emacs load path if it is a directory
|
# Add sub paths to the Emacs load path if it is a directory
|
||||||
# containing .el files. This is necessary to build some packages,
|
# containing .el files. This is necessary to build some packages,
|
||||||
# e.g., using trivialBuild.
|
# e.g., using trivialBuild.
|
||||||
|
@ -34,7 +34,15 @@ in customEmacsPackages.emacsWithPackages (epkgs: [ epkgs.evil epkgs.magit ])
|
|||||||
|
|
||||||
{ lib, lndir, makeWrapper, runCommand }: self:
|
{ 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
|
packagesFun: # packages explicitly requested by the user
|
||||||
|
|
||||||
@ -95,6 +103,9 @@ runCommand
|
|||||||
}
|
}
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
mkdir -p $out/share/emacs/site-lisp
|
mkdir -p $out/share/emacs/site-lisp
|
||||||
|
${optionalString emacs.nativeComp ''
|
||||||
|
mkdir -p $out/share/emacs/native-lisp
|
||||||
|
''}
|
||||||
|
|
||||||
local requires
|
local requires
|
||||||
for pkg in $explicitRequires; do
|
for pkg in $explicitRequires; do
|
||||||
@ -116,6 +127,9 @@ runCommand
|
|||||||
linkEmacsPackage() {
|
linkEmacsPackage() {
|
||||||
linkPath "$1" "bin" "bin"
|
linkPath "$1" "bin" "bin"
|
||||||
linkPath "$1" "share/emacs/site-lisp" "share/emacs/site-lisp"
|
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)
|
# 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")
|
(load-file "$emacs/share/emacs/site-lisp/site-start.el")
|
||||||
(add-to-list 'load-path "$out/share/emacs/site-lisp")
|
(add-to-list 'load-path "$out/share/emacs/site-lisp")
|
||||||
(add-to-list 'exec-path "$out/bin")
|
(add-to-list 'exec-path "$out/bin")
|
||||||
|
${optionalString nativeComp ''
|
||||||
|
(add-to-list 'comp-eln-load-path "$out/share/emacs/native-lisp/")
|
||||||
|
''}
|
||||||
EOF
|
EOF
|
||||||
# Link subdirs.el from the emacs distribution
|
# Link subdirs.el from the emacs distribution
|
||||||
ln -s $emacs/share/emacs/site-lisp/subdirs.el -T $subdirs
|
ln -s $emacs/share/emacs/site-lisp/subdirs.el -T $subdirs
|
||||||
|
|
||||||
# Byte-compiling improves start-up time only slightly, but costs nothing.
|
# Byte-compiling improves start-up time only slightly, but costs nothing.
|
||||||
$emacs/bin/emacs --batch -f batch-byte-compile "$siteStart" "$subdirs"
|
$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;
|
inherit (emacs) meta;
|
||||||
@ -159,8 +182,14 @@ runCommand
|
|||||||
substitute ${./wrapper.sh} $out/bin/$progname \
|
substitute ${./wrapper.sh} $out/bin/$progname \
|
||||||
--subst-var-by bash ${emacs.stdenv.shell} \
|
--subst-var-by bash ${emacs.stdenv.shell} \
|
||||||
--subst-var-by wrapperSiteLisp "$deps/share/emacs/site-lisp" \
|
--subst-var-by wrapperSiteLisp "$deps/share/emacs/site-lisp" \
|
||||||
|
--subst-var-by wrapperSiteLispNative "$deps/share/emacs/native-lisp:" \
|
||||||
--subst-var prog
|
--subst-var prog
|
||||||
chmod +x $out/bin/$progname
|
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
|
done
|
||||||
|
|
||||||
# Wrap MacOS app
|
# Wrap MacOS app
|
||||||
@ -173,11 +202,16 @@ runCommand
|
|||||||
$emacs/Applications/Emacs.app/Contents/Resources \
|
$emacs/Applications/Emacs.app/Contents/Resources \
|
||||||
$out/Applications/Emacs.app/Contents
|
$out/Applications/Emacs.app/Contents
|
||||||
|
|
||||||
|
|
||||||
substitute ${./wrapper.sh} $out/Applications/Emacs.app/Contents/MacOS/Emacs \
|
substitute ${./wrapper.sh} $out/Applications/Emacs.app/Contents/MacOS/Emacs \
|
||||||
--subst-var-by bash ${emacs.stdenv.shell} \
|
--subst-var-by bash ${emacs.stdenv.shell} \
|
||||||
--subst-var-by wrapperSiteLisp "$deps/share/emacs/site-lisp" \
|
--subst-var-by wrapperSiteLisp "$deps/share/emacs/site-lisp" \
|
||||||
--subst-var-by prog "$emacs/Applications/Emacs.app/Contents/MacOS/Emacs"
|
--subst-var-by prog "$emacs/Applications/Emacs.app/Contents/MacOS/Emacs"
|
||||||
chmod +x $out/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
|
fi
|
||||||
|
|
||||||
mkdir -p $out/share
|
mkdir -p $out/share
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
IFS=:
|
IFS=:
|
||||||
|
|
||||||
newLoadPath=()
|
newLoadPath=()
|
||||||
|
newNativeLoadPath=()
|
||||||
added=
|
added=
|
||||||
|
|
||||||
if [[ -n $EMACSLOADPATH ]]
|
if [[ -n $EMACSLOADPATH ]]
|
||||||
@ -21,7 +22,26 @@ else
|
|||||||
newLoadPath+=("")
|
newLoadPath+=("")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -n $EMACSNATIVELOADPATH ]]
|
||||||
|
then
|
||||||
|
while read -rd: entry
|
||||||
|
do
|
||||||
|
if [[ -z $entry && -z $added ]]
|
||||||
|
then
|
||||||
|
newNativeLoadPath+=(@wrapperSiteLispNative@)
|
||||||
|
added=1
|
||||||
|
fi
|
||||||
|
newNativeLoadPath+=("$entry")
|
||||||
|
done <<< "$EMACSNATIVELOADPATH:"
|
||||||
|
else
|
||||||
|
newNativeLoadPath+=(@wrapperSiteLispNative@)
|
||||||
|
newNativeLoadPath+=("")
|
||||||
|
fi
|
||||||
|
|
||||||
export EMACSLOADPATH="${newLoadPath[*]}"
|
export EMACSLOADPATH="${newLoadPath[*]}"
|
||||||
export emacsWithPackages_siteLisp=@wrapperSiteLisp@
|
export emacsWithPackages_siteLisp=@wrapperSiteLisp@
|
||||||
|
|
||||||
|
export EMACSNATIVELOADPATH="${newNativeLoadPath[*]}"
|
||||||
|
export emacsWithPackages_siteLispNative=@wrapperSiteLispNative@
|
||||||
|
|
||||||
exec @prog@ "$@"
|
exec @prog@ "$@"
|
||||||
|
Loading…
Reference in New Issue
Block a user