From 17cbd62a717254999c9bc2a1368008f04a0c6360 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Tue, 23 Jan 2024 19:12:58 -0500 Subject: [PATCH] ghc/hadrian: Respect patches --- pkgs/development/compilers/ghc/common-hadrian.nix | 6 +++++- .../haskell/hadrian/disable-hyperlinked-source.patch | 4 ++-- pkgs/development/tools/haskell/hadrian/hadrian.nix | 9 ++++----- pkgs/development/tools/haskell/hadrian/make-hadrian.nix | 3 ++- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/pkgs/development/compilers/ghc/common-hadrian.nix b/pkgs/development/compilers/ghc/common-hadrian.nix index f4d2a279a6782..5e95250497512 100644 --- a/pkgs/development/compilers/ghc/common-hadrian.nix +++ b/pkgs/development/compilers/ghc/common-hadrian.nix @@ -148,11 +148,15 @@ inherit rev; }) + # Patches applied to both GHC and Hadrian. +, patches ? [] + # GHC's build system hadrian built from the GHC-to-build's source tree # using our bootstrap GHC. , hadrian ? import ../../tools/haskell/hadrian/make-hadrian.nix { inherit bootPkgs lib; } { ghcSrc = ghcSrc; ghcVersion = version; + inherit patches; userSettings = hadrianUserSettings; # Disable haddock generating pretty source listings to stay under 3GB on aarch64-linux enableHyperlinkedSource = @@ -277,7 +281,7 @@ stdenv.mkDerivation ({ # elimination on aarch64-darwin. (see # https://github.com/NixOS/nixpkgs/issues/140774 for details). ./Cabal-at-least-3.6-paths-fix-cycle-aarch64-darwin.patch - ]; + ] ++ patches; postPatch = '' patchShebangs --build . 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.nix b/pkgs/development/tools/haskell/hadrian/hadrian.nix index 1be21d6f45196..68587550419ee 100644 --- a/pkgs/development/tools/haskell/hadrian/hadrian.nix +++ b/pkgs/development/tools/haskell/hadrian/hadrian.nix @@ -9,6 +9,7 @@ # GHC source tree to build hadrian from , ghcSrc , ghcVersion +, patches ? [] # Customization , userSettings ? null , enableHyperlinkedSource @@ -18,15 +19,13 @@ mkDerivation { pname = "hadrian"; version = ghcVersion; src = ghcSrc; - postUnpack = '' - sourceRoot="$sourceRoot/hadrian" - ''; - patches = lib.optionals (!enableHyperlinkedSource) [ + patches = patches ++ lib.optionals (!enableHyperlinkedSource) [ ./disable-hyperlinked-source.patch ]; # Overwrite UserSettings.hs with a provided custom one postPatch = lib.optionalString (userSettings != null) '' - install -m644 "${writeText "UserSettings.hs" userSettings}" src/UserSettings.hs + install -m644 "${writeText "UserSettings.hs" userSettings}" hadrian/src/UserSettings.hs + cd hadrian ''; configureFlags = [ # avoid QuickCheck dep which needs shared libs / TH diff --git a/pkgs/development/tools/haskell/hadrian/make-hadrian.nix b/pkgs/development/tools/haskell/hadrian/make-hadrian.nix index 6aa30cb9e60c3..8bcc1d0d83b9d 100644 --- a/pkgs/development/tools/haskell/hadrian/make-hadrian.nix +++ b/pkgs/development/tools/haskell/hadrian/make-hadrian.nix @@ -29,6 +29,7 @@ # These are passed on to the actual package expressions. ghcSrc , ghcVersion +, patches # Contents of a non-default UserSettings.hs to use when building hadrian, if any. # Should be a string or null. , userSettings ? null @@ -50,7 +51,7 @@ let in callPackage' ./hadrian.nix ({ - inherit userSettings enableHyperlinkedSource; + inherit userSettings enableHyperlinkedSource patches; } // 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