Fix use of isDarwin conditionals.

This commit is contained in:
Judah Jacobson 2017-05-05 09:53:08 -07:00
parent 7131e06214
commit 2caa7b88ae
2 changed files with 38 additions and 42 deletions

View File

@ -228,25 +228,23 @@ stdenv.mkDerivation ({
configureFlags+=" --extra-lib-dirs=$p/lib" configureFlags+=" --extra-lib-dirs=$p/lib"
fi fi
done done
'' + (optionalString stdenv.isDarwin ''
if "${if stdenv.isDarwin then "true" else "false"}"; then # Work around a limit in the Mac OS X Sierra linker on the number of paths
# Work around a limit in the Mac OS X Sierra linker on the number of paths # referenced by any one dynamic library:
# referenced by any one dynamic library: #
# # Create a local directory with symlinks of the *.dylib (Mac OS X shared
# Create a local directory with symlinks of the *.dylib (Mac OS X shared # libraries) from all the dependencies.
# libraries) from all the dependencies. local dynamicLinksDir="$out/lib/links"
local dynamicLinksDir="$out/lib/links" mkdir -p $dynamicLinksDir
mkdir -p $dynamicLinksDir local foundDylib=false
local foundDylib=false for d in $(grep dynamic-library-dirs $packageConfDir/*|awk '{print $2}'); do
for d in $(grep dynamic-library-dirs $packageConfDir/*|awk '{print $2}'); do ln -s $d/*.dylib $dynamicLinksDir
ln -s $d/*.dylib $dynamicLinksDir done
done # Edit the local package DB to reference the links directory.
# Edit the local package DB to reference the links directory. for f in $packageConfDir/*.conf; do
for f in $packageConfDir/*.conf; do sed -i "s,dynamic-library-dirs: .*,dynamic-library-dirs: $dynamicLinksDir," $f
sed -i "s,dynamic-library-dirs: .*,dynamic-library-dirs: $dynamicLinksDir," $f done
done '') + ''
fi
${ghcCommand}-pkg --${packageDbFlag}="$packageConfDir" recache ${ghcCommand}-pkg --${packageDbFlag}="$packageConfDir" recache
runHook postSetupCompilerEnvironment runHook postSetupCompilerEnvironment

View File

@ -96,30 +96,28 @@ symlinkJoin {
makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "${packageDBFlag}=${packageCfgDir}" makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "${packageDBFlag}=${packageCfgDir}"
fi fi
done done
'' + (lib.optionalString stdenv.isDarwin ''
# Work around a linker limit in Mac OS X Sierra (see generic-builder.nix): # Work around a linker limit in Mac OS X Sierra (see generic-builder.nix):
if "${if stdenv.isDarwin then "true" else "false"}"; then local packageConfDir="$out/lib/${ghc.name}/package.conf.d";
local packageConfDir="$out/lib/${ghc.name}/package.conf.d"; local dynamicLinksDir="$out/lib/links"
local dynamicLinksDir="$out/lib/links" mkdir -p $dynamicLinksDir
mkdir -p $dynamicLinksDir # Clean up the old links that may have been (transitively) included by
# Clean up the old links that may have been (transitively) included by # symlinkJoin:
# symlinkJoin: rm -f $dynamicLinksDir/*
rm -f $dynamicLinksDir/* for d in $(grep dynamic-library-dirs $packageConfDir/*|awk '{print $2}'); do
for d in $(grep dynamic-library-dirs $packageConfDir/*|awk '{print $2}'); do ln -s $d/*.dylib $dynamicLinksDir
ln -s $d/*.dylib $dynamicLinksDir done
done for f in $packageConfDir/*.conf; do
for f in $packageConfDir/*.conf; do # Initially, $f is a symlink to a read-only file in one of the inputs
# Initially, $f is a symlink to a read-only file in one of the inputs # (as a result of this symlinkJoin derivation).
# (as a result of this symlinkJoin derivation). # Replace it with a copy whose dynamic-library-dirs points to
# Replace it with a copy whose dynamic-library-dirs points to # $dynamicLinksDir
# $dynamicLinksDir cp $f $f-tmp
cp $f $f-tmp rm $f
rm $f sed "s,dynamic-library-dirs: .*,dynamic-library-dirs: $dynamicLinksDir," $f-tmp > $f
sed "s,dynamic-library-dirs: .*,dynamic-library-dirs: $dynamicLinksDir," $f-tmp > $f rm $f-tmp
rm $f-tmp done
done '') + ''
fi
${lib.optionalString hasLibraries "$out/bin/${ghcCommand}-pkg recache"} ${lib.optionalString hasLibraries "$out/bin/${ghcCommand}-pkg recache"}
${# ghcjs will read the ghc_libdir file when resolving plugins. ${# ghcjs will read the ghc_libdir file when resolving plugins.
lib.optionalString (isGhcjs && ghcLibdir != null) '' lib.optionalString (isGhcjs && ghcLibdir != null) ''