about summary refs log tree commit diff
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2017-05-05 18:39:35 -0400
committerShea Levy <shea@shealevy.com>2017-05-05 18:39:35 -0400
commita1748f7b5ccae44501eb30e1e4e9fc2fabbbb0bf (patch)
tree1ecd020ad356fbc9f2db952f13aac5592f136520
parentc15a17eb841c143b294ac9bc1370d8687470c365 (diff)
parent2caa7b88ae52caccac9c1b07c52af0080e9417c3 (diff)
downloadnixlib-a1748f7b5ccae44501eb30e1e4e9fc2fabbbb0bf.tar
nixlib-a1748f7b5ccae44501eb30e1e4e9fc2fabbbb0bf.tar.gz
nixlib-a1748f7b5ccae44501eb30e1e4e9fc2fabbbb0bf.tar.bz2
nixlib-a1748f7b5ccae44501eb30e1e4e9fc2fabbbb0bf.tar.lz
nixlib-a1748f7b5ccae44501eb30e1e4e9fc2fabbbb0bf.tar.xz
nixlib-a1748f7b5ccae44501eb30e1e4e9fc2fabbbb0bf.tar.zst
nixlib-a1748f7b5ccae44501eb30e1e4e9fc2fabbbb0bf.zip
Merge remote-tracking branch 'takt/sierra-haskell'
-rw-r--r--pkgs/development/haskell-modules/generic-builder.nix17
-rw-r--r--pkgs/development/haskell-modules/with-packages-wrapper.nix23
2 files changed, 39 insertions, 1 deletions
diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix
index f2b98e541e81..65569dfb9ba1 100644
--- a/pkgs/development/haskell-modules/generic-builder.nix
+++ b/pkgs/development/haskell-modules/generic-builder.nix
@@ -228,6 +228,23 @@ stdenv.mkDerivation ({
         configureFlags+=" --extra-lib-dirs=$p/lib"
       fi
     done
+  '' + (optionalString stdenv.isDarwin ''
+    # Work around a limit in the Mac OS X Sierra linker on the number of paths
+    # referenced by any one dynamic library:
+    #
+    # Create a local directory with symlinks of the *.dylib (Mac OS X shared
+    # libraries) from all the dependencies.
+    local dynamicLinksDir="$out/lib/links"
+    mkdir -p $dynamicLinksDir
+    local foundDylib=false
+    for d in $(grep dynamic-library-dirs $packageConfDir/*|awk '{print $2}'); do
+      ln -s $d/*.dylib $dynamicLinksDir
+    done
+    # Edit the local package DB to reference the links directory.
+    for f in $packageConfDir/*.conf; do
+      sed -i "s,dynamic-library-dirs: .*,dynamic-library-dirs: $dynamicLinksDir," $f
+    done
+  '') + ''
     ${ghcCommand}-pkg --${packageDbFlag}="$packageConfDir" recache
 
     runHook postSetupCompilerEnvironment
diff --git a/pkgs/development/haskell-modules/with-packages-wrapper.nix b/pkgs/development/haskell-modules/with-packages-wrapper.nix
index 15d66bbd6dc0..147a021ff534 100644
--- a/pkgs/development/haskell-modules/with-packages-wrapper.nix
+++ b/pkgs/development/haskell-modules/with-packages-wrapper.nix
@@ -96,7 +96,28 @@ symlinkJoin {
         makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "${packageDBFlag}=${packageCfgDir}"
       fi
     done
-
+  '' + (lib.optionalString stdenv.isDarwin ''
+    # Work around a linker limit in Mac OS X Sierra (see generic-builder.nix):
+    local packageConfDir="$out/lib/${ghc.name}/package.conf.d";
+    local dynamicLinksDir="$out/lib/links"
+    mkdir -p $dynamicLinksDir
+    # Clean up the old links that may have been (transitively) included by
+    # symlinkJoin:
+    rm -f $dynamicLinksDir/*
+    for d in $(grep dynamic-library-dirs $packageConfDir/*|awk '{print $2}'); do
+      ln -s $d/*.dylib $dynamicLinksDir
+    done
+    for f in $packageConfDir/*.conf; do
+      # Initially, $f is a symlink to a read-only file in one of the inputs
+      # (as a result of this symlinkJoin derivation).
+      # Replace it with a copy whose dynamic-library-dirs points to
+      # $dynamicLinksDir
+      cp $f $f-tmp
+      rm $f
+      sed "s,dynamic-library-dirs: .*,dynamic-library-dirs: $dynamicLinksDir," $f-tmp > $f
+      rm $f-tmp
+    done
+  '') + ''
     ${lib.optionalString hasLibraries "$out/bin/${ghcCommand}-pkg recache"}
     ${# ghcjs will read the ghc_libdir file when resolving plugins.
       lib.optionalString (isGhcjs && ghcLibdir != null) ''