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" + # 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 + 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" + linkPath() { + local pkg=$1 + local origin_path=$2 + local dest_path=$3 - # 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" <"$siteStart" <