nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 71 lines 2.7 kB view raw
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. 6# 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. 12# 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. 17# 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. 24{ 25 bootPkgs, 26 lib, 27}: 28 29{ 30 # GHC source tree and version to build hadrian & friends from. 31 # These are passed on to the actual package expressions. 32 ghcSrc, 33 ghcVersion, 34 # Contents of a non-default UserSettings.hs to use when building hadrian, if any. 35 # Should be a string or null. 36 userSettings ? null, 37}: 38 39let 40 callPackage' = 41 f: args: 42 bootPkgs.callPackage f ( 43 { 44 inherit ghcSrc ghcVersion; 45 } 46 // args 47 ); 48 49 ghc-platform = callPackage' ./ghc-platform.nix { }; 50 ghc-toolchain = callPackage' ./ghc-toolchain.nix { 51 inherit ghc-platform; 52 }; 53in 54 55callPackage' ./hadrian.nix ( 56 { 57 inherit userSettings; 58 # Taking `ghc` as an input may be too confusing 59 bootGhcVersion = bootPkgs.ghc.version; 60 } 61 // lib.optionalAttrs (lib.versionAtLeast ghcVersion "9.9") { 62 # Starting with GHC 9.9 development, additional in tree packages are required 63 # to build hadrian. (Hackage-released conditional dependencies are handled 64 # in ./hadrian.nix without requiring intervention here.) 65 inherit ghc-platform ghc-toolchain; 66 } 67 // lib.optionalAttrs (lib.versionAtLeast ghcVersion "9.11") { 68 # See https://gitlab.haskell.org/ghc/ghc/-/commit/145a6477854d4003a07573d5e7ffa0c9a64ae29c 69 Cabal = bootPkgs.Cabal_3_14_2_0; 70 } 71)