From d9bb0c4f376ee1436f3b1787ebe8b27ac40322d3 Mon Sep 17 00:00:00 2001
From: Hamish Mackenzie <Hamish.K.Mackenzie@gmail.com>
Date: Mon, 24 Mar 2025 17:03:55 +1300
Subject: [PATCH 1/2] Remove overlay/ghc.nix

It breaks the `override` function on the ghc compilers and it only serves to add "stackprotector" to `hardeningDisable`.  We can just add that to `compiler/ghc/default.nix`.

It looks like it also added "format", but that is already present.  For `hostPlatform.isAarch32` it adds "pie" (not already present), but we don't build GHC on 32bit arm.
---
 compiler/ghc/default.nix |  2 +-
 overlays/default.nix     |  2 --
 overlays/ghc.nix         | 29 -----------------------------
 3 files changed, 1 insertion(+), 32 deletions(-)
 delete mode 100644 overlays/ghc.nix

diff --git a/compiler/ghc/default.nix b/compiler/ghc/default.nix
index 11be98da5..671055716 100644
--- a/compiler/ghc/default.nix
+++ b/compiler/ghc/default.nix
@@ -546,7 +546,7 @@ stdenv.mkDerivation (rec {
 
   checkTarget = "test";
 
-  hardeningDisable = [ "format" ]
+  hardeningDisable = [ "format" "stackprotector" ]
                    ++ lib.optional stdenv.targetPlatform.isAarch32 "pic"
                    ++ lib.optional stdenv.targetPlatform.isMusl "pie"
                    ++ lib.optional enableDWARF "fortify";
diff --git a/overlays/default.nix b/overlays/default.nix
index 2a87eca02..bb5a18f65 100644
--- a/overlays/default.nix
+++ b/overlays/default.nix
@@ -76,7 +76,6 @@ let
 
     bootstrap = import ./bootstrap.nix;
     compiler-llvm = import ./compiler-llvm.nix;
-    ghc = import ./ghc.nix;
     ghc-packages = import ./ghc-packages.nix;
     darwin = import ./darwin.nix;
     windows = import ./windows.nix;
@@ -114,7 +113,6 @@ let
     nix-tools
     bootstrap
     compiler-llvm
-    ghc
     ghc-packages
     darwin
     windows
diff --git a/overlays/ghc.nix b/overlays/ghc.nix
deleted file mode 100644
index ec2d1b302..000000000
--- a/overlays/ghc.nix
+++ /dev/null
@@ -1,29 +0,0 @@
-_final: prev: with prev;
-  # sadly we need to patch GHC a bit.
-  let
-    ghcDrvOverrides = drv: {
-        hardeningDisable = (drv.hardeningDisable or []) ++ [ "stackprotector" "format" ] ++ lib.optionals prev.stdenv.hostPlatform.isAarch32 [ "pic" "pie" ];
-      };
-   in {
-   haskell-nix = let
-     # These patches (ghcDrvOverrides) only apply to vanilla source ghcs.
-     # Not ghcjs or binary distributions.
-     # We also ignore ghc82. And are only concerned with ghc84+
-     # we want to apply this only to non-ghcjs ones.
-     # As we do some ghc <- ghcjs mapping for ghcjs.
-     needsPatches = name:
-       !(prev.stdenv.targetPlatform.isGhcjs or false)
-       && lib.hasPrefix "ghc" name
-       && !lib.hasPrefix "ghc82" name
-       && !lib.hasPrefix "ghcjs" name
-       && !lib.hasSuffix "Binary" name;
-     overrideCompiler = name: compiler:
-       (compiler.overrideAttrs ghcDrvOverrides) // {
-         dwarf = overrideCompiler name compiler.dwarf;
-       };
-   in
-     lib.recursiveUpdate prev.haskell-nix {
-       compiler = lib.mapAttrs overrideCompiler
-         (lib.filterAttrs (name: _value: needsPatches name) prev.haskell-nix.compiler);
-     };
-   }

From baa97e31f1af61ef306dceef61ba79e113040a13 Mon Sep 17 00:00:00 2001
From: Hamish Mackenzie <Hamish.K.Mackenzie@gmail.com>
Date: Wed, 26 Mar 2025 13:11:22 +1300
Subject: [PATCH 2/2] Update default compiler to GHC 9.6.6 (from 9.2.8)

---
 flake.nix            | 2 +-
 hix/init/nix/hix.nix | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/flake.nix b/flake.nix
index 24d0689fa..0c5ba1956 100644
--- a/flake.nix
+++ b/flake.nix
@@ -85,7 +85,7 @@
 
       ifdLevel = 3;
       runningHydraEvalTest = false;
-      defaultCompiler = "ghc928";
+      defaultCompiler = "ghc966";
       config = import ./config.nix;
 
       inherit (nixpkgs) lib;
diff --git a/hix/init/nix/hix.nix b/hix/init/nix/hix.nix
index 7112e3aed..d01778f7c 100644
--- a/hix/init/nix/hix.nix
+++ b/hix/init/nix/hix.nix
@@ -1,6 +1,6 @@
 {pkgs, ...}: {
   # name = "project-name";
-  compiler-nix-name = "ghc92"; # Version of GHC to use
+  compiler-nix-name = "ghc96"; # Version of GHC to use
 
   # Cross compilation support:
   # crossPlatforms = p: pkgs.lib.optionals pkgs.stdenv.hostPlatform.isx86_64 ([