@@ -51,8 +51,11 @@ stdenv.mkDerivation {
5151 inherit emacs explicitRequires;
5252 phases = [ "installPhase" ];
5353 installPhase = ''
54− mkdir -p $out/bin
55− mkdir -p $out/share/emacs/site-lisp
54+ readonly SHARE="share/emacs-with-packages"
55+
56+ mkdir -p "$out/bin"
57+ mkdir -p "$out/$SHARE/bin"
58+ mkdir -p "$out/$SHARE/site-lisp"
5659
5760 local requires
5861 for pkg in $explicitRequires; do
@@ -60,29 +63,32 @@ stdenv.mkDerivation {
6063 done
6164 # requires now holds all requested packages and their transitive dependencies
6265
63− siteStart="$out/share/emacs/site-lisp/site-start.el"
66+ siteStart="$out/$SHARE/site-lisp/site-start.el"
6467
6568 # Begin the new site-start.el by loading the original, which sets some
6669 # NixOS-specific paths. Paths are searched in the reverse of the order
6770 # they are specified in, so user and system profile paths are searched last.
6871 cat >"$siteStart" <<EOF
6972(load-file "$emacs/share/emacs/site-lisp/site-start.el")
70−(add-to-list 'load-path "$out/share/emacs/site-lisp")
73+(add-to-list 'load-path "$out/$SHARE/site-lisp")
74+(add-to-list 'exec-path "$out/$SHARE/bin")
7175EOF
7276
7377 linkPath() {
7478 local pkg=$1
75− local path=$2
79+ local origin_path=$2
80+ local dest_path=$3
81+
7682 # Add the path to the search path list, but only if it exists
77− if [[ -d "$pkg/$path" ]]; then
78− lndir -silent "$pkg/$path" "$out/$path"
83+ if [[ -d "$pkg/$origin_path" ]]; then
84+ lndir -silent "$pkg/$origin_path" "$out/$dest_path"
7985 fi
8086 }
8187
8288 # Add a package's paths to site-start.el
8389 linkEmacsPackage() {
84− linkPath "$1" "bin"
85− linkPath "$1" "share/emacs/site-lisp"
90+ linkPath "$1" "bin" "$SHARE/bin"
91+ linkPath "$1" "share/emacs/site-lisp" "$SHARE/site-lisp"
8692 }
8793
8894 # First, link all the explicitly-required packages.
@@ -103,7 +109,7 @@ EOF
103109 local progname=$(basename "$prog")
104110 rm -f "$out/bin/$progname"
105111 makeWrapper "$prog" "$out/bin/$progname" \
106− --suffix EMACSLOADPATH ":" "$out/share/emacs/site-lisp:"
112+ --suffix EMACSLOADPATH ":" "$out/$SHARE/site-lisp:"
107113 done
108114
109115 mkdir -p $out/share