Files
haskell.nix/builder/default.nix
Hamish Mackenzie 6c7f9d0042 Use cabal 3.8 (#1641)
A bug was fixed in cabal 3.8 (https://github.com/haskell/cabal/issues/6771) that haskell.nix relied on for `pkg-config` in support.  To work around this we added a dummy `pkg-config` that `cabal configure` now uses when haskell.nix runs it `cabal configure` internally.  That returns version information for all the `pkg-config` packages in `lib/pkgconfig-nixpkgs-map.nix`.  This mapping has also been expanded based on the results of searching nixpkgs for `*.pc` files.

This update also includes workarounds for:

https://github.com/haskell/cabal/issues/8352
https://github.com/haskell/cabal/issues/8370
https://github.com/haskell/cabal/issues/8455
2022-09-13 12:00:04 +12:00

94 lines
3.7 KiB
Nix

{ pkgs, buildPackages, evalPackages, stdenv, lib, haskellLib, ghc, compiler-nix-name, fetchurl, pkgconfig, nonReinstallablePkgs, hsPkgs, compiler }:
let
# Builds a single component of a package.
comp-builder = haskellLib.weakCallPackage pkgs ./comp-builder.nix {
inherit ghc haskellLib makeConfigFiles haddockBuilder ghcForComponent hsPkgs compiler;
};
haddockBuilder = haskellLib.weakCallPackage pkgs ./haddock-builder.nix {
inherit ghc ghcForComponent haskellLib makeConfigFiles nonReinstallablePkgs;
};
setup-builder = haskellLib.weakCallPackage pkgs ./setup-builder.nix {
ghc = (ghc.passthru.buildGHC or ghc);
hsPkgs = hsPkgs.buildPackages;
# We need to use the buildPackages stdenv to build the setup-builder.
# in the native case, it would be the same in the cross case however
# we *really* want to build the Setup.hs on the build machine and not
# have the stdenv confuse it with the target/host env.
inherit (buildPackages) stdenv;
inherit buildPackages;
inherit haskellLib nonReinstallablePkgs makeSetupConfigFiles;
};
# Wraps GHC to provide dependencies in a way that works for both the
# component builder and for nix-shells.
ghcForComponent = import ./ghc-for-component-wrapper.nix {
inherit lib ghc haskellLib;
inherit (buildPackages) stdenv;
inherit (buildPackages.buildPackages) runCommand makeWrapper;
inherit (buildPackages.buildPackages.xorg) lndir;
};
# Builds a derivation which contains a ghc package-db of
# dependencies for a component.
makeConfigFiles = haskellLib.weakCallPackage pkgs ./make-config-files.nix {
inherit ghc haskellLib nonReinstallablePkgs;
};
# When building setup depends we need to use the build systems GHC and Packages
makeSetupConfigFiles = haskellLib.weakCallPackage buildPackages ./make-config-files.nix {
inherit haskellLib nonReinstallablePkgs;
ghc = (ghc.passthru.buildGHC or ghc);
};
hoogleLocal = let
nixpkgsHoogle = import (pkgs.path + /pkgs/development/haskell-modules/hoogle.nix);
in { packages ? [], hoogle ? pkgs.buildPackages.haskell-nix.tool "ghc8107" "hoogle" {
inherit evalPackages;
version = "5.0.18.3";
index-state = pkgs.haskell-nix.internalHackageIndexState;
}
}:
let
haskellPackages = {
# For musl we can use haddock from the buildGHC
ghc = if stdenv.hostPlatform.isLinux && stdenv.targetPlatform.isMusl && !haskellLib.isNativeMusl
then ghc.buildGHC
else ghc;
inherit packages hoogle;
};
in if lib.versionAtLeast lib.trivial.release "22.05"
then haskellLib.weakCallPackage pkgs nixpkgsHoogle {
inherit haskellPackages;
} (p: p.packages)
else haskellLib.weakCallPackage pkgs nixpkgsHoogle haskellPackages;
# Same as haskellPackages.shellFor in nixpkgs.
shellFor = haskellLib.weakCallPackage pkgs ./shell-for.nix {
inherit hsPkgs ghcForComponent makeConfigFiles hoogleLocal haskellLib buildPackages evalPackages compiler;
inherit (buildPackages) glibcLocales;
};
# Same as haskellPackages.ghcWithPackages and ghcWithHoogle in nixpkgs.
withPackages = {withHoogle}: packages: (shellFor {
name = ghc.name + "-with-packages";
packages = _: [];
additional = packages;
inherit withHoogle;
}).ghc;
in {
# Build a Haskell package from its config.
# TODO: this pkgs is the adjusted pkgs, but pkgs.pkgs is unadjusted
build-package = haskellLib.weakCallPackage pkgs ./hspkg-builder.nix {
inherit haskellLib ghc compiler-nix-name comp-builder setup-builder;
};
inherit shellFor makeConfigFiles;
ghcWithPackages = withPackages { withHoogle = false; };
ghcWithHoogle = withPackages { withHoogle = true; };
}