···228228 configureFlags+=" --extra-lib-dirs=$p/lib"
229229 fi
230230 done
231231+ '' + (optionalString stdenv.isDarwin ''
232232+ # Work around a limit in the Mac OS X Sierra linker on the number of paths
233233+ # referenced by any one dynamic library:
234234+ #
235235+ # Create a local directory with symlinks of the *.dylib (Mac OS X shared
236236+ # libraries) from all the dependencies.
237237+ local dynamicLinksDir="$out/lib/links"
238238+ mkdir -p $dynamicLinksDir
239239+ local foundDylib=false
240240+ for d in $(grep dynamic-library-dirs $packageConfDir/*|awk '{print $2}'); do
241241+ ln -s $d/*.dylib $dynamicLinksDir
242242+ done
243243+ # Edit the local package DB to reference the links directory.
244244+ for f in $packageConfDir/*.conf; do
245245+ sed -i "s,dynamic-library-dirs: .*,dynamic-library-dirs: $dynamicLinksDir," $f
246246+ done
247247+ '') + ''
231248 ${ghcCommand}-pkg --${packageDbFlag}="$packageConfDir" recache
232249233250 runHook postSetupCompilerEnvironment
···9696 makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "${packageDBFlag}=${packageCfgDir}"
9797 fi
9898 done
9999-9999+ '' + (lib.optionalString stdenv.isDarwin ''
100100+ # Work around a linker limit in Mac OS X Sierra (see generic-builder.nix):
101101+ local packageConfDir="$out/lib/${ghc.name}/package.conf.d";
102102+ local dynamicLinksDir="$out/lib/links"
103103+ mkdir -p $dynamicLinksDir
104104+ # Clean up the old links that may have been (transitively) included by
105105+ # symlinkJoin:
106106+ rm -f $dynamicLinksDir/*
107107+ for d in $(grep dynamic-library-dirs $packageConfDir/*|awk '{print $2}'); do
108108+ ln -s $d/*.dylib $dynamicLinksDir
109109+ done
110110+ for f in $packageConfDir/*.conf; do
111111+ # Initially, $f is a symlink to a read-only file in one of the inputs
112112+ # (as a result of this symlinkJoin derivation).
113113+ # Replace it with a copy whose dynamic-library-dirs points to
114114+ # $dynamicLinksDir
115115+ cp $f $f-tmp
116116+ rm $f
117117+ sed "s,dynamic-library-dirs: .*,dynamic-library-dirs: $dynamicLinksDir," $f-tmp > $f
118118+ rm $f-tmp
119119+ done
120120+ '') + ''
100121 ${lib.optionalString hasLibraries "$out/bin/${ghcCommand}-pkg recache"}
101122 ${# ghcjs will read the ghc_libdir file when resolving plugins.
102123 lib.optionalString (isGhcjs && ghcLibdir != null) ''