diff options
author | Samuel Rivas <samuelrivas@gmail.com> | 2016-05-12 22:15:40 +0200 |
---|---|---|
committer | Samuel Rivas <samuelrivas@gmail.com> | 2016-05-12 22:43:30 +0200 |
commit | 67394f91528e8e7031de1174b56619ae56cddd01 (patch) | |
tree | f501ac8057f8ccb5be5d0c749df298a72ee30dd5 /pkgs/build-support/emacs | |
parent | 95c7dd7af9334a77c84c22326b25a0ff1a036084 (diff) | |
download | nixpkgs-67394f91528e8e7031de1174b56619ae56cddd01.tar nixpkgs-67394f91528e8e7031de1174b56619ae56cddd01.tar.gz nixpkgs-67394f91528e8e7031de1174b56619ae56cddd01.tar.bz2 nixpkgs-67394f91528e8e7031de1174b56619ae56cddd01.tar.lz nixpkgs-67394f91528e8e7031de1174b56619ae56cddd01.tar.xz nixpkgs-67394f91528e8e7031de1174b56619ae56cddd01.tar.zst nixpkgs-67394f91528e8e7031de1174b56619ae56cddd01.zip |
emacs: hide wrapper dependencies
Move all the dependencies to their own derivation, so that we don't publish all of them if the wrapper is installed in a profile. The previous solution just moved them to a custom directory to avoid conflicts, this refactors that and completely hides them, while preserving the desired improvement of adding only one directory to each of the emacs search paths
Diffstat (limited to 'pkgs/build-support/emacs')
-rw-r--r-- | pkgs/build-support/emacs/wrapper.nix | 104 |
1 files changed, 53 insertions, 51 deletions
diff --git a/pkgs/build-support/emacs/wrapper.nix b/pkgs/build-support/emacs/wrapper.nix index 7be4d21bfa8..45931e6914a 100644 --- a/pkgs/build-support/emacs/wrapper.nix +++ b/pkgs/build-support/emacs/wrapper.nix @@ -32,7 +32,7 @@ in customEmacsPackages.emacsWithPackages (epkgs: [ epkgs.evil epkgs.magit ]) */ -{ lib, lndir, makeWrapper, stdenv }: self: +{ lib, lndir, makeWrapper, runCommand, stdenv }: self: with lib; let inherit (self) emacs; in @@ -49,67 +49,69 @@ stdenv.mkDerivation { name = (appendToName "with-packages" emacs).name; nativeBuildInputs = [ emacs lndir makeWrapper ]; inherit emacs explicitRequires; - phases = [ "installPhase" ]; - installPhase = '' - readonly SHARE="share/emacs-with-packages" - - mkdir -p "$out/bin" - mkdir -p "$out/$SHARE/bin" - mkdir -p "$out/$SHARE/site-lisp" - - local requires - for pkg in $explicitRequires; do - findInputs $pkg requires propagated-user-env-packages - done - # requires now holds all requested packages and their transitive dependencies - - siteStart="$out/$SHARE/site-lisp/site-start.el" - # 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 - # they are specified in, so user and system profile paths are searched last. - cat >"$siteStart" <<EOF + # Store all paths we want to add to emacs here, so that we only need to add + # one path to the load lists + deps = runCommand "emacs-packages-deps" + { inherit explicitRequires lndir emacs; } + '' + mkdir -p $out/bin + mkdir -p $out/share/emacs/site-lisp + + local requires + for pkg in $explicitRequires; do + findInputs $pkg requires propagated-user-env-packages + done + # requires now holds all requested packages and their transitive dependencies + + linkPath() { + local pkg=$1 + local origin_path=$2 + local dest_path=$3 + + # Add the path to the search path list, but only if it exists + if [[ -d "$pkg/$origin_path" ]]; then + $lndir/bin/lndir -silent "$pkg/$origin_path" "$out/$dest_path" + fi + } + + linkEmacsPackage() { + linkPath "$1" "bin" "bin" + linkPath "$1" "share/emacs/site-lisp" "share/emacs/site-lisp" + } + + for pkg in $requires; do + linkEmacsPackage $pkg + done + + siteStart="$out/share/emacs/site-lisp/site-start.el" + + # A dependency may have brought the original siteStart, delete it and + # create our own + # 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 + # they are specified in, so user and system profile paths are searched last. + rm -f $siteStart + cat >"$siteStart" <<EOF (load-file "$emacs/share/emacs/site-lisp/site-start.el") -(add-to-list 'load-path "$out/$SHARE/site-lisp") -(add-to-list 'exec-path "$out/$SHARE/bin") +(add-to-list 'load-path "$out/share/emacs/site-lisp") +(add-to-list 'exec-path "$out/bin") EOF - linkPath() { - local pkg=$1 - local origin_path=$2 - local dest_path=$3 - - # Add the path to the search path list, but only if it exists - if [[ -d "$pkg/$origin_path" ]]; then - lndir -silent "$pkg/$origin_path" "$out/$dest_path" - fi - } - - # Add a package's paths to site-start.el - linkEmacsPackage() { - linkPath "$1" "bin" "$SHARE/bin" - linkPath "$1" "share/emacs/site-lisp" "$SHARE/site-lisp" - } - - # First, link all the explicitly-required packages. - for pkg in $explicitRequires; do - linkEmacsPackage $pkg - done - - # Next, link all the dependencies. - for pkg in $requires; do - linkEmacsPackage $pkg - done + # Byte-compiling improves start-up time only slightly, but costs nothing. + $emacs/bin/emacs --batch -f batch-byte-compile "$siteStart" + ''; - # Byte-compiling improves start-up time only slightly, but costs nothing. - emacs --batch -f batch-byte-compile "$siteStart" + phases = [ "installPhase" ]; + installPhase = '' + mkdir -p "$out/bin" # Wrap emacs and friends so they find our site-start.el before the original. for prog in $emacs/bin/*; do # */ local progname=$(basename "$prog") rm -f "$out/bin/$progname" makeWrapper "$prog" "$out/bin/$progname" \ - --suffix EMACSLOADPATH ":" "$out/$SHARE/site-lisp:" + --suffix EMACSLOADPATH ":" "$deps/share/emacs/site-lisp:" done mkdir -p $out/share |