emacsWithPackages: defer loading package.el

Also stops duplicating load paths.
This commit is contained in:
Thomas Tuegel 2016-01-20 12:43:21 -06:00
parent 97e1258ded
commit 2b1024646b

View File

@ -68,11 +68,10 @@ stdenv.mkDerivation {
fi fi
} }
# Add a dependency's paths to site-start.el # Add a package's paths to site-start.el
addToEmacsPaths() { addEmacsPackage() {
addEmacsPath "exec-path" "$1/bin" addEmacsPath "exec-path" "$1/bin"
addEmacsPath "load-path" "$1/share/emacs/site-lisp" addEmacsPath "load-path" "$1/share/emacs/site-lisp"
addEmacsPath "package-directory-list" "$1/share/emacs/site-lisp/elpa"
} }
mkdir -p $out/share/emacs/site-lisp mkdir -p $out/share/emacs/site-lisp
@ -80,7 +79,6 @@ stdenv.mkDerivation {
# NixOS-specific paths. Paths are searched in the reverse of the order # NixOS-specific paths. Paths are searched in the reverse of the order
# they are specified in, so user and system profile paths are searched last. # they are specified in, so user and system profile paths are searched last.
echo "(load-file \"$emacs/share/emacs/site-lisp/site-start.el\")" >"$siteStart" echo "(load-file \"$emacs/share/emacs/site-lisp/site-start.el\")" >"$siteStart"
echo "(require 'package)" >>"$siteStart"
# Set paths for the dependencies of the requested packages. These paths are # Set paths for the dependencies of the requested packages. These paths are
# searched before the profile paths, but after the explicitly-required paths. # searched before the profile paths, but after the explicitly-required paths.
@ -88,14 +86,14 @@ stdenv.mkDerivation {
# The explicitly-required packages are also in the list, but we will add # The explicitly-required packages are also in the list, but we will add
# those paths last. # those paths last.
if ! ( echo "$explicitRequires" | grep "$pkg" >/dev/null ) ; then if ! ( echo "$explicitRequires" | grep "$pkg" >/dev/null ) ; then
addToEmacsPaths $pkg addEmacsPackage $pkg
fi fi
done done
# Finally, add paths for all the explicitly-required packages. These paths # Finally, add paths for all the explicitly-required packages. These paths
# will be searched first. # will be searched first.
for pkg in $explicitRequires; do for pkg in $explicitRequires; do
addToEmacsPaths $pkg addEmacsPackage $pkg
done done
# Byte-compiling improves start-up time only slightly, but costs nothing. # Byte-compiling improves start-up time only slightly, but costs nothing.