diff options
Diffstat (limited to 'pkgs/development/tools/haskell')
-rw-r--r-- | pkgs/development/tools/haskell/hadrian/ghc-platform.nix | 16 | ||||
-rw-r--r-- | pkgs/development/tools/haskell/hadrian/ghc-toolchain.nix | 19 | ||||
-rw-r--r-- | pkgs/development/tools/haskell/hadrian/hadrian.nix (renamed from pkgs/development/tools/haskell/hadrian/default.nix) | 29 | ||||
-rw-r--r-- | pkgs/development/tools/haskell/hadrian/make-hadrian.nix | 59 |
4 files changed, 111 insertions, 12 deletions
diff --git a/pkgs/development/tools/haskell/hadrian/ghc-platform.nix b/pkgs/development/tools/haskell/hadrian/ghc-platform.nix new file mode 100644 index 000000000000..3b1b17fba2c7 --- /dev/null +++ b/pkgs/development/tools/haskell/hadrian/ghc-platform.nix @@ -0,0 +1,16 @@ +{ mkDerivation, base, lib + # GHC source tree to build ghc-toolchain from +, ghcSrc +, ghcVersion +}: +mkDerivation { + pname = "ghc-platform"; + version = ghcVersion; + src = ghcSrc; + postUnpack = '' + sourceRoot="$sourceRoot/libraries/ghc-platform" + ''; + libraryHaskellDepends = [ base ]; + description = "Platform information used by GHC and friends"; + license = lib.licenses.bsd3; +} diff --git a/pkgs/development/tools/haskell/hadrian/ghc-toolchain.nix b/pkgs/development/tools/haskell/hadrian/ghc-toolchain.nix new file mode 100644 index 000000000000..035fee7aca80 --- /dev/null +++ b/pkgs/development/tools/haskell/hadrian/ghc-toolchain.nix @@ -0,0 +1,19 @@ +{ mkDerivation, base, directory, filepath, ghc-platform, lib +, process, text, transformers + # GHC source tree to build ghc-toolchain from +, ghcVersion +, ghcSrc +}: +mkDerivation { + pname = "ghc-toolchain"; + version = ghcVersion; + src = ghcSrc; + postUnpack = '' + sourceRoot="$sourceRoot/utils/ghc-toolchain" + ''; + libraryHaskellDepends = [ + base directory filepath ghc-platform process text transformers + ]; + description = "Utility for managing GHC target toolchains"; + license = lib.licenses.bsd3; +} diff --git a/pkgs/development/tools/haskell/hadrian/default.nix b/pkgs/development/tools/haskell/hadrian/hadrian.nix index 1801d63cf8b9..1be21d6f4519 100644 --- a/pkgs/development/tools/haskell/hadrian/default.nix +++ b/pkgs/development/tools/haskell/hadrian/hadrian.nix @@ -1,20 +1,19 @@ -{ # GHC source tree to build hadrian from - ghcSrc ? null, ghcVersion ? null -, mkDerivation, base, bytestring, Cabal, containers, directory +# See also ./make-hadria.nix +{ mkDerivation, base, bytestring, Cabal, containers, directory , extra, filepath, lib, mtl, parsec, shake, text, transformers , unordered-containers, cryptohash-sha256, base16-bytestring -, userSettings ? null -# Whether to pass --hyperlinked-source to haddock or not. This is a custom -# workaround as we wait for this to be configurable via userSettings or similar. -# https://gitlab.haskell.org/ghc/ghc/-/issues/23625 -, enableHyperlinkedSource ? true , writeText + # Dependencies that are not on Hackage and only used in certain Hadrian versions +, ghc-platform ? null +, ghc-toolchain ? null + # GHC source tree to build hadrian from +, ghcSrc +, ghcVersion + # Customization +, userSettings ? null +, enableHyperlinkedSource }: -if ghcSrc == null || ghcVersion == null -then throw "hadrian: need to specify ghcSrc and ghcVersion arguments manually" -else - mkDerivation { pname = "hadrian"; version = ghcVersion; @@ -44,7 +43,13 @@ mkDerivation { parsec shake text transformers unordered-containers ] ++ lib.optionals (lib.versionAtLeast ghcVersion "9.7") [ cryptohash-sha256 base16-bytestring + ] ++ lib.optionals (lib.versionAtLeast ghcVersion "9.9") [ + ghc-platform ghc-toolchain ]; + passthru = { + # Expose »private« dependencies if any + inherit ghc-platform ghc-toolchain; + }; description = "GHC build system"; license = lib.licenses.bsd3; } diff --git a/pkgs/development/tools/haskell/hadrian/make-hadrian.nix b/pkgs/development/tools/haskell/hadrian/make-hadrian.nix new file mode 100644 index 000000000000..6aa30cb9e60c --- /dev/null +++ b/pkgs/development/tools/haskell/hadrian/make-hadrian.nix @@ -0,0 +1,59 @@ +# Hadrian is the build system used to (exclusively) build GHC. It can +# (theoretically) be used starting with GHC 9.4 and is required since 9.6. It is +# developed in the GHC source tree and specific to the GHC version it is released +# with, i.e. Hadrian always needs to be built from the same GHC source tree as +# the GHC we want to build. +# +# This fact makes it impossible to integrate Hadrian into our Haskell package +# sets which are also used to bootstrap GHC, since a package set can bootstrap +# multiple GHC versions (usually two major versions). A bootstrap set would need +# knowledge of the GHC it would eventually bootstrap which would make the logic +# unnecessarily complicated. +# +# Luckily Hadrian is, while annoying to bootstrap, relatively simple. Specifically +# all it requires to build is (relative to the GHC we are trying to build) a +# build->build GHC and build->build Haskell packages. We can get all of this +# from bootPkgs which is already passed to the GHC expression. +# +# The solution is the following: The GHC expression passes its source tree and +# version along with some parameters to this function (./make-hadrian.nix) +# which acts as a common expression builder for all Hadrian version as well as +# related packages that are managed in the GHC source tree. Its main job is to +# expose all possible compile time customization in a common interface and +# take care of all differences between Hadrian versions. +{ bootPkgs +, lib +}: + +{ # GHC source tree and version to build hadrian & friends from. + # These are passed on to the actual package expressions. + ghcSrc +, ghcVersion + # Contents of a non-default UserSettings.hs to use when building hadrian, if any. + # Should be a string or null. +, userSettings ? null + # Whether to pass --hyperlinked-source to haddock or not. This is a custom + # workaround as we wait for this to be configurable via userSettings or similar. + # https://gitlab.haskell.org/ghc/ghc/-/issues/23625 +, enableHyperlinkedSource ? false +}: + +let + callPackage' = f: args: bootPkgs.callPackage f ({ + inherit ghcSrc ghcVersion; + } // args); + + ghc-platform = callPackage' ./ghc-platform.nix { }; + ghc-toolchain = callPackage' ./ghc-toolchain.nix { + inherit ghc-platform; + }; +in + +callPackage' ./hadrian.nix ({ + inherit userSettings enableHyperlinkedSource; +} // lib.optionalAttrs (lib.versionAtLeast ghcVersion "9.9") { + # Starting with GHC 9.9 development, additional in tree packages are required + # to build hadrian. (Hackage-released conditional dependencies are handled + # in ./hadrian.nix without requiring intervention here.) + inherit ghc-platform ghc-toolchain; +}) |