emacsWithPackages: reduce some duplication

This commit is contained in:
Samuel Rivas 2016-04-03 21:21:50 +02:00
parent 2b199537b7
commit f1b0d6410e

View File

@ -51,9 +51,11 @@ stdenv.mkDerivation {
inherit emacs explicitRequires; inherit emacs explicitRequires;
phases = [ "installPhase" ]; phases = [ "installPhase" ];
installPhase = '' installPhase = ''
mkdir -p $out/bin readonly SHARE="share/emacs-with-packages"
mkdir -p $out/share/emacs-with-packages/bin
mkdir -p $out/share/emacs-with-packages/site-lisp mkdir -p "$out/bin"
mkdir -p "$out/$SHARE/bin"
mkdir -p "$out/$SHARE/site-lisp"
local requires local requires
for pkg in $explicitRequires; do for pkg in $explicitRequires; do
@ -61,15 +63,15 @@ stdenv.mkDerivation {
done done
# requires now holds all requested packages and their transitive dependencies # requires now holds all requested packages and their transitive dependencies
siteStart="$out/share/emacs-with-packages/site-lisp/site-start.el" siteStart="$out/$SHARE/site-lisp/site-start.el"
# Begin the new site-start.el by loading the original, which sets some # Begin the new site-start.el by loading the original, which sets some
# 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.
cat >"$siteStart" <<EOF cat >"$siteStart" <<EOF
(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-with-packages/site-lisp") (add-to-list 'load-path "$out/$SHARE/site-lisp")
(add-to-list 'exec-path "$out/share/emacs-with-packages/bin") (add-to-list 'exec-path "$out/$SHARE/bin")
EOF EOF
linkPath() { linkPath() {
@ -85,8 +87,8 @@ EOF
# Add a package's paths to site-start.el # Add a package's paths to site-start.el
linkEmacsPackage() { linkEmacsPackage() {
linkPath "$1" "bin" "share/emacs-with-packages/bin" linkPath "$1" "bin" "$SHARE/bin"
linkPath "$1" "share/emacs/site-lisp" "share/emacs-with-packages/site-lisp" linkPath "$1" "share/emacs/site-lisp" "$SHARE/site-lisp"
} }
# First, link all the explicitly-required packages. # First, link all the explicitly-required packages.
@ -107,7 +109,7 @@ EOF
local progname=$(basename "$prog") local progname=$(basename "$prog")
rm -f "$out/bin/$progname" rm -f "$out/bin/$progname"
makeWrapper "$prog" "$out/bin/$progname" \ makeWrapper "$prog" "$out/bin/$progname" \
--suffix EMACSLOADPATH ":" "$out/share/emacs-with-packages/site-lisp:" --suffix EMACSLOADPATH ":" "$out/$SHARE/site-lisp:"
done done
mkdir -p $out/share mkdir -p $out/share