···228 configureFlags+=" --extra-lib-dirs=$p/lib"
229 fi
230 done
231+ '' + (optionalString stdenv.isDarwin ''
232+ # Work around a limit in the Mac OS X Sierra linker on the number of paths
233+ # referenced by any one dynamic library:
234+ #
235+ # Create a local directory with symlinks of the *.dylib (Mac OS X shared
236+ # libraries) from all the dependencies.
237+ local dynamicLinksDir="$out/lib/links"
238+ mkdir -p $dynamicLinksDir
239+ local foundDylib=false
240+ for d in $(grep dynamic-library-dirs $packageConfDir/*|awk '{print $2}'); do
241+ ln -s $d/*.dylib $dynamicLinksDir
242+ done
243+ # Edit the local package DB to reference the links directory.
244+ for f in $packageConfDir/*.conf; do
245+ sed -i "s,dynamic-library-dirs: .*,dynamic-library-dirs: $dynamicLinksDir," $f
246+ done
247+ '') + ''
248 ${ghcCommand}-pkg --${packageDbFlag}="$packageConfDir" recache
249250 runHook postSetupCompilerEnvironment
···96 makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "${packageDBFlag}=${packageCfgDir}"
97 fi
98 done
99-000000000000000000000100 ${lib.optionalString hasLibraries "$out/bin/${ghcCommand}-pkg recache"}
101 ${# ghcjs will read the ghc_libdir file when resolving plugins.
102 lib.optionalString (isGhcjs && ghcLibdir != null) ''
···96 makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "${packageDBFlag}=${packageCfgDir}"
97 fi
98 done
99+ '' + (lib.optionalString stdenv.isDarwin ''
100+ # Work around a linker limit in Mac OS X Sierra (see generic-builder.nix):
101+ local packageConfDir="$out/lib/${ghc.name}/package.conf.d";
102+ local dynamicLinksDir="$out/lib/links"
103+ mkdir -p $dynamicLinksDir
104+ # Clean up the old links that may have been (transitively) included by
105+ # symlinkJoin:
106+ rm -f $dynamicLinksDir/*
107+ for d in $(grep dynamic-library-dirs $packageConfDir/*|awk '{print $2}'); do
108+ ln -s $d/*.dylib $dynamicLinksDir
109+ done
110+ for f in $packageConfDir/*.conf; do
111+ # Initially, $f is a symlink to a read-only file in one of the inputs
112+ # (as a result of this symlinkJoin derivation).
113+ # Replace it with a copy whose dynamic-library-dirs points to
114+ # $dynamicLinksDir
115+ cp $f $f-tmp
116+ rm $f
117+ sed "s,dynamic-library-dirs: .*,dynamic-library-dirs: $dynamicLinksDir," $f-tmp > $f
118+ rm $f-tmp
119+ done
120+ '') + ''
121 ${lib.optionalString hasLibraries "$out/bin/${ghcCommand}-pkg recache"}
122 ${# ghcjs will read the ghc_libdir file when resolving plugins.
123 lib.optionalString (isGhcjs && ghcLibdir != null) ''