Unverified Commit d41710e9 authored by Wolfgang Walther's avatar Wolfgang Walther Committed by GitHub
Browse files

haskell.packages.*.ghcWithPackages: Fix on darwin (#415434)

parents 570a6ab2 030221d2
Loading
Loading
Loading
Loading
+9 −13
Original line number Diff line number Diff line
@@ -62,13 +62,6 @@ let
    else
      "$out/lib/${ghc.targetPrefix}${ghc.haskellCompilerName}"
      + lib.optionalString (ghc ? hadrian) "/lib";
  # Boot libraries for GHC are present in a separate directory.
  bootLibDir =
    let
      arch = if stdenv.targetPlatform.isAarch64 then "aarch64" else "x86_64";
      platform = if stdenv.targetPlatform.isDarwin then "osx" else "linux";
    in
    "${ghc}/lib/${ghc.haskellCompilerName}/lib/${arch}-${platform}-${ghc.haskellCompilerName}";
  docDir = "$out/share/doc/ghc/html";
  packageCfgDir = "${libDir}/package.conf.d";
  paths = lib.concatLists (
@@ -154,14 +147,17 @@ else
          # symlinkJoin:
          rm -f $dynamicLinksDir/*

          # Boot libraries are located differently than other libraries since GHC 9.6, so handle them separately.
          if [[ -x "${bootLibDir}" ]]; then
            find "${bootLibDir}" -name '*.dylib' -exec ln -s {} "$dynamicLinksDir" \;
          fi
          dynamicLibraryDirs=()

          for d in $(grep -Poz "dynamic-library-dirs:\s*\K .+\n" $packageConfDir/*|awk '{print $2}'|sort -u); do
            find "$d" -name '*.dylib' -exec ln -s {} "$dynamicLinksDir" \;
          for pkg in $($out/bin/ghc-pkg list --simple-output); do
            dynamicLibraryDirs+=($($out/bin/ghc-pkg --simple-output field "$pkg" dynamic-library-dirs))
          done

          for dynamicLibraryDir in $(echo "''${dynamicLibraryDirs[@]}" | tr ' ' '\n' | sort -u); do
            echo "Linking $dynamicLibraryDir/*.dylib from $dynamicLinksDir"
            find "$dynamicLibraryDir" -name '*.dylib' -exec ln -s {} "$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).