about summary refs log tree commit diff
diff options
context:
space:
mode:
authorsternenseemann <sternenseemann@systemli.org>2024-04-17 00:51:15 +0200
committersternenseemann <sternenseemann@systemli.org>2024-04-27 15:03:02 +0200
commitc93aff17d599feb24ca6a0e2156afd3b184a7afb (patch)
treedeb3284063f28ab9a01b27b89739f5b7d656349c
parent675bcbb917a13567e3fad8bb00afada19db791d6 (diff)
haskell.compiler.ghc9{6,8}: apply hadrian patches to shared ghcSrc
This makes the hadrian expressions much simpler as we no longer need to
thread through extra arguments for special workarounds.
common-hadrian.nix decides in one place which patches we need and
directly applies them to the source used to build everything.
-rw-r--r--pkgs/development/compilers/ghc/common-hadrian.nix23
-rw-r--r--pkgs/development/tools/haskell/hadrian/disable-hyperlinked-source.patch4
-rw-r--r--pkgs/development/tools/haskell/hadrian/hadrian-9.8.1-allow-Cabal-3.10.patch4
-rw-r--r--pkgs/development/tools/haskell/hadrian/hadrian.nix8
-rw-r--r--pkgs/development/tools/haskell/hadrian/make-hadrian.nix6
5 files changed, 23 insertions, 22 deletions
diff --git a/pkgs/development/compilers/ghc/common-hadrian.nix b/pkgs/development/compilers/ghc/common-hadrian.nix
index f1f160c1224cc..5db97cc0d976e 100644
--- a/pkgs/development/compilers/ghc/common-hadrian.nix
+++ b/pkgs/development/compilers/ghc/common-hadrian.nix
@@ -159,6 +159,12 @@
         });
 
       patches =
+        let
+          # Disable haddock generating pretty source listings to stay under 3GB on aarch64-linux
+          enableHyperlinkedSource =
+            lib.versionAtLeast version "9.8" ||
+            !(stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isLinux);
+        in
         [
           # Fix docs build with Sphinx >= 7 https://gitlab.haskell.org/ghc/ghc/-/issues/24129
           (if lib.versionAtLeast version "9.8"
@@ -174,6 +180,18 @@
           # https://github.com/NixOS/nixpkgs/issues/140774 for details).
           ./Cabal-at-least-3.6-paths-fix-cycle-aarch64-darwin.patch
         ]
+        # Prevents passing --hyperlinked-source to haddock. 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
+        ++ lib.optionals (!enableHyperlinkedSource) [
+          # TODO(@sternenseemann): Doesn't apply for GHC >= 9.8
+          ../../tools/haskell/hadrian/disable-hyperlinked-source.patch
+        ]
+        # Incorrect bounds on Cabal in hadrian
+        # https://gitlab.haskell.org/ghc/ghc/-/issues/24100
+        ++ lib.optionals (lib.elem version [ "9.8.1" "9.8.2" ]) [
+          ../../tools/haskell/hadrian/hadrian-9.8.1-allow-Cabal-3.10.patch
+        ];
     }
 
   # GHC's build system hadrian built from the GHC-to-build's source tree
@@ -182,11 +200,6 @@
     inherit ghcSrc;
     ghcVersion = version;
     userSettings = hadrianUserSettings;
-    # Disable haddock generating pretty source listings to stay under 3GB on aarch64-linux
-    enableHyperlinkedSource =
-      # TODO(@sternenseemann): Disabling currently doesn't work with GHC >= 9.8
-      lib.versionAtLeast version "9.8" ||
-      !(stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isLinux);
   }
 
 , #  Whether to build sphinx documentation.
diff --git a/pkgs/development/tools/haskell/hadrian/disable-hyperlinked-source.patch b/pkgs/development/tools/haskell/hadrian/disable-hyperlinked-source.patch
index 72010f85cddc4..103871bb65e12 100644
--- a/pkgs/development/tools/haskell/hadrian/disable-hyperlinked-source.patch
+++ b/pkgs/development/tools/haskell/hadrian/disable-hyperlinked-source.patch
@@ -1,7 +1,7 @@
 diff --git a/hadrian/src/Settings/Builders/Haddock.hs b/hadrian/src/Settings/Builders/Haddock.hs
 index 902b2f85e2..429a441c3b 100644
---- a/src/Settings/Builders/Haddock.hs
-+++ b/src/Settings/Builders/Haddock.hs
+--- a/hadrian/src/Settings/Builders/Haddock.hs
++++ b/hadrian/src/Settings/Builders/Haddock.hs
 @@ -57,7 +57,6 @@ haddockBuilderArgs = mconcat
              , arg $ "--odir=" ++ takeDirectory output
              , arg $ "--dump-interface=" ++ output
diff --git a/pkgs/development/tools/haskell/hadrian/hadrian-9.8.1-allow-Cabal-3.10.patch b/pkgs/development/tools/haskell/hadrian/hadrian-9.8.1-allow-Cabal-3.10.patch
index d813fef31c8d5..eccf1a987d06a 100644
--- a/pkgs/development/tools/haskell/hadrian/hadrian-9.8.1-allow-Cabal-3.10.patch
+++ b/pkgs/development/tools/haskell/hadrian/hadrian-9.8.1-allow-Cabal-3.10.patch
@@ -1,7 +1,7 @@
 diff --git a/hadrian.cabal b/hadrian.cabal
 index 70fded11aa..3893537f05 100644
---- a/hadrian.cabal
-+++ b/hadrian.cabal
+--- a/hadrian/hadrian.cabal
++++ b/hadrian/hadrian.cabal
 @@ -150,7 +150,7 @@ executable hadrian
                         , TypeOperators
      other-extensions:    MultiParamTypeClasses
diff --git a/pkgs/development/tools/haskell/hadrian/hadrian.nix b/pkgs/development/tools/haskell/hadrian/hadrian.nix
index 7a44e2eeffc29..d1368427f0c9f 100644
--- a/pkgs/development/tools/haskell/hadrian/hadrian.nix
+++ b/pkgs/development/tools/haskell/hadrian/hadrian.nix
@@ -11,7 +11,6 @@
 , ghcVersion
   # Customization
 , userSettings ? null
-, enableHyperlinkedSource
 }:
 
 mkDerivation {
@@ -21,13 +20,6 @@ mkDerivation {
   postUnpack = ''
     sourceRoot="$sourceRoot/hadrian"
   '';
-  patches = lib.optionals (!enableHyperlinkedSource) [
-    ./disable-hyperlinked-source.patch
-  ] ++ lib.optionals (lib.elem ghcVersion [ "9.8.1" "9.8.2" ]) [
-    # Incorrect bounds on Cabal
-    # https://gitlab.haskell.org/ghc/ghc/-/issues/24100
-    ./hadrian-9.8.1-allow-Cabal-3.10.patch
-  ];
   # Overwrite UserSettings.hs with a provided custom one
   postPatch = lib.optionalString (userSettings != null) ''
     install -m644 "${writeText "UserSettings.hs" userSettings}" src/UserSettings.hs
diff --git a/pkgs/development/tools/haskell/hadrian/make-hadrian.nix b/pkgs/development/tools/haskell/hadrian/make-hadrian.nix
index 6aa30cb9e60c3..fb9ee89f7cdb9 100644
--- a/pkgs/development/tools/haskell/hadrian/make-hadrian.nix
+++ b/pkgs/development/tools/haskell/hadrian/make-hadrian.nix
@@ -32,10 +32,6 @@
   # 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
@@ -50,7 +46,7 @@ let
 in
 
 callPackage' ./hadrian.nix ({
-  inherit userSettings enableHyperlinkedSource;
+  inherit userSettings;
 } // 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