summary refs log tree commit diff
path: root/pkgs/build-support/emacs/wrapper.nix
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2018-01-04 12:15:31 -0500
committerShea Levy <shea@shealevy.com>2018-01-04 12:15:55 -0500
commit0f925943fdeafd7f6813488aac587e9c989e6e91 (patch)
tree5592db0c5cbfbac7a20ba347cbdd5fcb4ddaaa72 /pkgs/build-support/emacs/wrapper.nix
parent1b0f696d109beebb5190eecaae4f5525b5ee8b06 (diff)
downloadnixlib-0f925943fdeafd7f6813488aac587e9c989e6e91.tar
nixlib-0f925943fdeafd7f6813488aac587e9c989e6e91.tar.gz
nixlib-0f925943fdeafd7f6813488aac587e9c989e6e91.tar.bz2
nixlib-0f925943fdeafd7f6813488aac587e9c989e6e91.tar.lz
nixlib-0f925943fdeafd7f6813488aac587e9c989e6e91.tar.xz
nixlib-0f925943fdeafd7f6813488aac587e9c989e6e91.tar.zst
nixlib-0f925943fdeafd7f6813488aac587e9c989e6e91.zip
Fix emacsWithPackages after 7f3ca3e21a22fd3101b40cadb86899542dec2e35.
This is hacky but it does the job, resurrects findInputs from before staging merge
Diffstat (limited to 'pkgs/build-support/emacs/wrapper.nix')
-rw-r--r--pkgs/build-support/emacs/wrapper.nix36
1 files changed, 35 insertions, 1 deletions
diff --git a/pkgs/build-support/emacs/wrapper.nix b/pkgs/build-support/emacs/wrapper.nix
index bd733f1b9baf..27633c912b23 100644
--- a/pkgs/build-support/emacs/wrapper.nix
+++ b/pkgs/build-support/emacs/wrapper.nix
@@ -55,12 +55,46 @@ stdenv.mkDerivation {
   deps = runCommand "emacs-packages-deps"
    { inherit explicitRequires lndir emacs; }
    ''
+     findInputsOld() {
+         local pkg="$1"; shift
+         local var="$1"; shift
+         local propagatedBuildInputsFiles=("$@")
+
+         # TODO(@Ericson2314): Restore using associative array once Darwin
+         # nix-shell doesn't use impure bash. This should replace the O(n)
+         # case with an O(1) hash map lookup, assuming bash is implemented
+         # well :D.
+         local varSlice="$var[*]"
+         # ''${..-} to hack around old bash empty array problem
+         case "''${!varSlice-}" in
+             *" $pkg "*) return 0 ;;
+         esac
+         unset -v varSlice
+
+         eval "$var"'+=("$pkg")'
+
+         if ! [ -e "$pkg" ]; then
+             echo "build input $pkg does not exist" >&2
+             exit 1
+         fi
+
+         local file
+         for file in "''${propagatedBuildInputsFiles[@]}"; do
+             file="$pkg/nix-support/$file"
+             [[ -f "$file" ]] || continue
+
+             local pkgNext
+             for pkgNext in $(< "$file"); do
+                 findInputsOld "$pkgNext" "$var" "''${propagatedBuildInputsFiles[@]}"
+             done
+         done
+     }
      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
+       findInputsOld $pkg requires propagated-user-env-packages
      done
      # requires now holds all requested packages and their transitive dependencies