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:     # libraries) from all the dependencies.
      local dynamicLinksDir="$out/lib/links"
      mkdir -p $dynamicLinksDir
      for d in $(grep dynamic-library-dirs "$packageConfDir/"*|awk '{print $2}'|sort -u); do
        ln -s "$d/"*.dylib $dynamicLinksDir
      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
  
negative.code:                      main = defaultMain
                     '';
  
    # This awk expression transforms a package conf file like
    #
    #   author:               John Doe <john-doe@example.com>
    #   description:
    #       The purpose of this library is to do
    #       foo and bar among other things
    #
    # into a more easily processeable form:
    #
    #   author: John Doe <john-doe@example.com>
    #   description: The purpose of this library is to do foo and bar among other things
    unprettyConf = builtins.toFile "unpretty-cabal-conf.awk" ''
      /^[^ ]+:/ {
        # When the line starts with a new field, terminate the previous one with a newline
        if (started == 1) print ""
        # to strip leading spaces
        $1=$1
        printf "%s", $0
        started=1
      }
  
      /^ +/ {
        # to strip leading spaces
        $1=$1
        printf " %s", $0
      }
  
      # Terminate the final field with a newline
      END { print "" }
    '';
  
    crossCabalFlags = [
      "--with-ghc=${ghcCommand}"
      "--with-ghc-pkg=${ghc.targetPrefix}ghc-pkg"
  