diff --git a/pkgs/development/haskell-modules/configuration-common.nix b/pkgs/development/haskell-modules/configuration-common.nix index 204c183ca355..eb55be69188d 100644 --- a/pkgs/development/haskell-modules/configuration-common.nix +++ b/pkgs/development/haskell-modules/configuration-common.nix @@ -1069,3 +1069,14 @@ self: super: { in { inherit amazonka amazonka-core amazonka-test; }) + +// + +# The actual Cabal library gets built while building its `Setup.hs`. +(let + inherit (pkgs.lib) filterAttrs flip mapAttrs hasPrefix; + cabals = filterAttrs (n: v: hasPrefix "Cabal_" n) super; + fixCabal = n: v: addSetupDepends v [ self.mtl self.parsec ]; +in + mapAttrs fixCabal cabals +) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index 1cc385864585..7f3ddc48103b 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -166,14 +166,8 @@ let "--configure-option=--host=${hostPlatform.config}" ] ++ crossCabalFlags); - useSeparateSetupDb = setupHaskellDepends != [] || isCross || isGhcjs; - setupCompileFlags = [ - (optionalString (!coreSetup) "-${nativePackageDbFlag}=${ - if useSeparateSetupDb - then "$setupPackageConfDir" - else "$packageConfDir" - }") + (optionalString (!coreSetup) "-${nativePackageDbFlag}=$setupPackageConfDir") (optionalString (isGhcjs || isHaLVM || versionOlder "7.8" ghc.version) "-j$NIX_BUILD_CORES") # https://github.com/haskell/cabal/issues/2398 (optionalString (versionOlder "7.10" ghc.version && !isHaLVM) "-threaded") @@ -270,10 +264,8 @@ stdenv.mkDerivation ({ echo "Build with ${ghc}." ${optionalString (hasActiveLibrary && hyperlinkSource) "export PATH=${hscolour}/bin:$PATH"} - '' + (optionalString useSeparateSetupDb '' setupPackageConfDir="$TMPDIR/setup-package.conf.d" mkdir -p $setupPackageConfDir - '') + '' packageConfDir="$TMPDIR/package.conf.d" mkdir -p $packageConfDir @@ -284,14 +276,13 @@ stdenv.mkDerivation ({ # dependencies for the build machine. # # pkgs* arrays defined in stdenv/setup.hs - + (optionalString useSeparateSetupDb '' + + '' for p in "''${pkgsBuildBuild[@]}" "''${pkgsBuildHost[@]}" "''${pkgsBuildTarget[@]}"; do ${buildPkgDb nativeGhc.name "$setupPackageConfDir"} done ${nativeGhcCommand}-pkg --${nativePackageDbFlag}="$setupPackageConfDir" recache - '') - - # For normal components + '' + # For normal components + '' for p in "''${pkgsHostHost[@]}" "''${pkgsHostTarget[@]}"; do ${buildPkgDb ghc.name "$packageConfDir"}