diff --git a/configuration-ghc-9.4.x.nix b/configuration-ghc-9.4.x.nix
new file mode 100644
index 0000000000000000000000000000000000000000..6b78a528a05b07a1a94c8310468eb0402c7ab997
--- /dev/null
+++ b/configuration-ghc-9.4.x.nix
@@ -0,0 +1,51 @@
+{ pkgs, haskellLib }:
+
+let
+  inherit (pkgs) fetchpatch lib;
+  inherit (lib) throwIfNot versionOlder;
+in
+
+self: super: {
+  llvmPackages = lib.dontRecurseIntoAttrs self.ghc.llvmPackages;
+
+  # Disable GHC core libraries.
+  array = null;
+  base = null;
+  binary = null;
+  bytestring = null;
+  Cabal = null;
+  Cabal-syntax = null;
+  containers = null;
+  deepseq = null;
+  directory = null;
+  exceptions = null;
+  filepath = null;
+  ghc-bignum = null;
+  ghc-boot = null;
+  ghc-boot-th = null;
+  ghc-compact = null;
+  ghc-heap = null;
+  ghc-prim = null;
+  ghci = null;
+  haskeline = null;
+  hpc = null;
+  integer-gmp = null;
+  libiserv = null;
+  mtl = null;
+  parsec = null;
+  pretty = null;
+  process = null;
+  rts = null;
+  stm = null;
+  system-cxx-std-lib = null;
+  template-haskell = null;
+  # GHC only builds terminfo if it is a native compiler
+  terminfo = if pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform then null else self.terminfo_0_4_1_5;
+  text = null;
+  time = null;
+  transformers = null;
+  unix = null;
+  # GHC only bundles the xhtml library if haddock is enabled, check if this is
+  # still the case when updating: https://gitlab.haskell.org/ghc/ghc/-/blob/0198841877f6f04269d6050892b98b5c3807ce4c/ghc.mk#L463
+  xhtml = if self.ghc.hasHaddock or true then null else self.xhtml_3000_2_2_1;
+}
diff --git a/flake.nix b/flake.nix
index 9677c6e360362fecbf03e7049ef9af9cf4d7da28..fba461beba6cbe44bdb93c8669a16ef5997d9255 100644
--- a/flake.nix
+++ b/flake.nix
@@ -18,13 +18,14 @@
         pkgs = import nixpkgs { inherit system; };
         horizon-gen-nix-app = get-flake horizon-gen-nix;
         configuration = import ./configuration.nix { inherit inputs pkgs; };
+        haskellLib = pkgs.haskell.lib.compose;
         hsPkgs = pkgs.callPackage (nixpkgs + /pkgs/development/haskell-modules) {
           buildHaskellPackages = pkgs.haskell.packages.ghc942;
-          configurationCommon = { pkgs, haskellLib }: self: super: { };
+          configurationCommon = {pkgs, haskellLib}: self: super: { };
           ghc = pkgs.haskell.compiler.ghc942;
           haskellLib = pkgs.haskell.lib.compose;
           initialPackages = import ./overlay.nix;
-          compilerConfig = pkgs.callPackage (nixpkgs + /pkgs/development/haskell-modules/configuration-ghc-9.4.x.nix) { haskellLib = pkgs.haskell.lib.compose; };
+          compilerConfig = pkgs.callPackage ./configuration-ghc-9.4.x.nix { haskellLib = haskellLib; };
         };
         hp' = pkgs.lib.filterAttrs
           (n: v: v != null