diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index e8195668c41..a6fd7bb0ba9 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -212,7 +212,16 @@ let nativeGhcCommand = "${nativeGhc.targetPrefix}ghc"; buildPkgDb = ghcName: packageConfDir: '' - if [ -d "$p/lib/${ghcName}/package.conf.d" ]; then + # If this dependency has a package database, then copy the contents of it, + # unless it is one of our GHCs. These can appear in our dependencies when + # we are doing native builds, and they have package databases in them, but + # we do not want to copy them over. + # + # We don't need to, since those packages will be provided by the GHC when + # we compile with it, and doing so can result in having multiple copies of + # e.g. Cabal in the database with the same name and version, which is + # ambiguous. + if [ -d "$p/lib/${ghcName}/package.conf.d" ] && [ "$p" != "${ghc}" ] && [ "$p" != "${nativeGhc}" ]; then cp -f "$p/lib/${ghcName}/package.conf.d/"*.conf ${packageConfDir}/ continue fi