anchor.diff:          rmdir "$packageConfFile"
         fi
         for packageConfFile in "$packageConfDir/"*; do
  -        local pkgId=$( ${gnused}/bin/sed -n -e ':a' -e '/^id:$/N; s/id:\n[ ]*\([^\n]*\).*$/\1/p; s/id:[ ]*\([^\n]*\)$/\1/p; ta' $packageConfFile )
  -        mv $packageConfFile $packageConfDir/$pkgId.conf
  +        local pkgId=$(gawk -f ${unprettyConf} "$packageConfFile" \
  +          | grep '^id:' | cut -d' ' -f2)
  +        mv "$packageConfFile" "$packageConfDir/$pkgId.conf"
         done
   
         # delete confdir if there are no libraries
  
positive.code:                      main = defaultMain
                     '';
  
    crossCabalFlags = [
      "--with-ghc=${ghcCommand}"
      "--with-ghc-pkg=${ghc.targetPrefix}ghc-pkg"
  
negative.code:     # libraries) from all the dependencies.
      local dynamicLinksDir="$out/lib/links"
      mkdir -p $dynamicLinksDir
  
      # Unprettify all package conf files before reading/writing them
      for d in "$packageConfDir/"*; do
        # gawk -i inplace seems to strip the last newline
        gawk -f ${unprettyConf} "$d" > tmp
        mv tmp "$d"
      done
  
      for d in $(grep '^dynamic-library-dirs:' "$packageConfDir"/* | cut -d' ' -f2- | tr ' ' '\n' | sort -u); do
        for lib in "$d/"*.dylib; do
          ln -s "$lib" "$dynamicLinksDir"
        done
      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
  