1 # Hadrian is the build system used to (exclusively) build GHC. It can
2 # (theoretically) be used starting with GHC 9.4 and is required since 9.6. It is
3 # developed in the GHC source tree and specific to the GHC version it is released
4 # with, i.e. Hadrian always needs to be built from the same GHC source tree as
5 # the GHC we want to build.
7 # This fact makes it impossible to integrate Hadrian into our Haskell package
8 # sets which are also used to bootstrap GHC, since a package set can bootstrap
9 # multiple GHC versions (usually two major versions). A bootstrap set would need
10 # knowledge of the GHC it would eventually bootstrap which would make the logic
11 # unnecessarily complicated.
13 # Luckily Hadrian is, while annoying to bootstrap, relatively simple. Specifically
14 # all it requires to build is (relative to the GHC we are trying to build) a
15 # build->build GHC and build->build Haskell packages. We can get all of this
16 # from bootPkgs which is already passed to the GHC expression.
18 # The solution is the following: The GHC expression passes its source tree and
19 # version along with some parameters to this function (./make-hadrian.nix)
20 # which acts as a common expression builder for all Hadrian version as well as
21 # related packages that are managed in the GHC source tree. Its main job is to
22 # expose all possible compile time customization in a common interface and
23 # take care of all differences between Hadrian versions.
28 { # GHC source tree and version to build hadrian & friends from.
29 # These are passed on to the actual package expressions.
32 # Contents of a non-default UserSettings.hs to use when building hadrian, if any.
33 # Should be a string or null.
35 # Whether to pass --hyperlinked-source to haddock or not. This is a custom
36 # workaround as we wait for this to be configurable via userSettings or similar.
37 # https://gitlab.haskell.org/ghc/ghc/-/issues/23625
38 , enableHyperlinkedSource ? false
42 callPackage' = f: args: bootPkgs.callPackage f ({
43 inherit ghcSrc ghcVersion;
46 ghc-platform = callPackage' ./ghc-platform.nix { };
47 ghc-toolchain = callPackage' ./ghc-toolchain.nix {
52 callPackage' ./hadrian.nix ({
53 inherit userSettings enableHyperlinkedSource;
54 } // lib.optionalAttrs (lib.versionAtLeast ghcVersion "9.9") {
55 # Starting with GHC 9.9 development, additional in tree packages are required
56 # to build hadrian. (Hackage-released conditional dependencies are handled
57 # in ./hadrian.nix without requiring intervention here.)
58 inherit ghc-platform ghc-toolchain;