From a7ed61ebf7619d30d72c0c93e9cec9ba65890c77 Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Sat, 24 Jan 2026 17:23:52 +0100 Subject: [PATCH] stack: adjust overrides to stack 3.9.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The main change is that stack now needs Cabal >= 3.14. GHC 9.10 unfortunately needs a lot of coaxing to build the Setup.hs against it, so the override is essentially specific to GHC 9.10.3 now. (As an aside, I think the fact that we can't really apply the constraints from setup-depends with Setup.hs is a strong argument for adding (optional?) support for cabal-install based builds…) --- .../haskell-modules/configuration-common.nix | 64 --------- .../configuration-ghc-9.10.x.nix | 45 ++++++ .../configuration-hackage2nix/main.yaml | 1 - .../haskell-modules/hackage-packages.nix | 135 ------------------ 4 files changed, 45 insertions(+), 200 deletions(-) diff --git a/pkgs/development/haskell-modules/configuration-common.nix b/pkgs/development/haskell-modules/configuration-common.nix index d179b4eb7141..756fd3345d6c 100644 --- a/pkgs/development/haskell-modules/configuration-common.nix +++ b/pkgs/development/haskell-modules/configuration-common.nix @@ -2136,70 +2136,6 @@ with haskellLib; ); gi-gtk-declarative-app-simple = doJailbreak super.gi-gtk-declarative-app-simple; - # stack-3.7.1 requires Cabal < 3.12 - stack = - let - stack' = super.stack.overrideScope (self: super: { hpack = self.hpack_0_38_1; }); - in - if lib.versionOlder self.ghc.version "9.10" then - stack' - else - lib.pipe - # to reduce rebuilds, don't override Cabal in the entire scope - ((stack'.override { Cabal = self.Cabal_3_10_3_0; }).overrideScope ( - self: super: - let - downgradeCabal = - drv: - lib.pipe drv [ - # Since Cabal and Cabal-syntax are in the global package db, we can't - # remove them from the available packages. Instead, we pass a constraint. - (appendConfigureFlags [ - "--constraint=Cabal<3.12" - "--constraint=Cabal-syntax<3.12" - ]) - (addBuildDepends [ - self.Cabal-syntax_3_10_3_0 - self.Cabal_3_10_3_0 - ]) - ]; - in - lib.mapAttrs (_: downgradeCabal) { - inherit (super) - hpack - hackage-security - pantry - rio-prettyprint - ; - } - )) - [ - # In order to apply a patch to a file with DOS line endings with GNU patch(1), - # we need to use --binary with a patch that has DOS line endings. - (overrideCabal (drv: { - prePatch = '' - ${drv.prePatch or ""} - patchFlags="--binary -p1" - ''; - })) - (appendPatch ( - pkgs.fetchpatch { - postFetch = '' - sed -e 's/$/\r/' -i "$out" - ''; - # Type equality operator warning and failure with text >= 2.1.2 - # We filter out all Cabal related changes from this patch as Cabal bumps may change the behavior of stack. - name = "stack-ghc-9.10.patch"; - url = "https://github.com/commercialhaskell/stack/commit/6a672dd12f25151707cf45e9823447334728d245.patch"; - hash = "sha256-MVwYIvFwiuBx9r6QUR0dHejmsQxVI6KFoZlujSXYJPM="; - includes = [ - "src/Stack/Prelude.hs" - "src/Stack/Types/CompilerBuild.hs" - ]; - } - )) - ]; - # 2023-04-09: haskell-ci needs Cabal-syntax 3.10 # 2024-03-21: pins specific version of ShellCheck # 2025-03-10: jailbreak, https://github.com/haskell-CI/haskell-ci/issues/771 diff --git a/pkgs/development/haskell-modules/configuration-ghc-9.10.x.nix b/pkgs/development/haskell-modules/configuration-ghc-9.10.x.nix index 66942b6809d4..adf516e84147 100644 --- a/pkgs/development/haskell-modules/configuration-ghc-9.10.x.nix +++ b/pkgs/development/haskell-modules/configuration-ghc-9.10.x.nix @@ -68,6 +68,51 @@ in # “Unfortunately we are unable to support GHC 9.10.” apply-refact = dontDistribute (markBroken super.apply-refact); + stack = + # Setup.hs depends on Cabal-syntax >= 3.14 + overrideCabal + (drv: { + setupHaskellDepends = drv.setupHaskellDepends or [ ] ++ [ + self.Cabal-syntax_3_14_2_0 + self.Cabal_3_14_2_0 + ]; + # We need to tell GHC to ignore the Cabal core libraries while + # compiling Setup.hs since it depends on Cabal >= 3.14. + # ATTN: This override assumes we are using GHC 9.10.3 since we need + # to give an exact Cabal version at the GHC (!) command line. + # FIXME(@sternenseemann): make direct argument to generic-builder.nix + env = drv.env or { } // { + setupCompileFlags = lib.concatStringsSep " " [ + "-hide-package" + "Cabal-syntax-3.12.1.0" + "-hide-package" + "Cabal-3.12.1.0" + ]; + }; + }) + + # Stack itself depends on Cabal >= 3.14 which also needs to be updated for deps + ( + super.stack.overrideScope ( + sself: ssuper: + let + upgradeCabal = + drv: + lib.pipe drv [ + (addBuildDepends [ sself.Cabal_3_14_2_0 ]) + (appendConfigureFlags [ "--constraint=Cabal>=3.14" ]) + ]; + in + { + pantry = upgradeCabal ssuper.pantry_0_11_2; + rio-prettyprint = upgradeCabal ssuper.rio-prettyprint; + hackage-security = upgradeCabal ssuper.hackage-security; + hpack = upgradeCabal sself.hpack_0_39_1; + stack = upgradeCabal ssuper.stack; + } + ) + ); + # # Version upgrades # diff --git a/pkgs/development/haskell-modules/configuration-hackage2nix/main.yaml b/pkgs/development/haskell-modules/configuration-hackage2nix/main.yaml index 3582699b0b10..f2491f1f7434 100644 --- a/pkgs/development/haskell-modules/configuration-hackage2nix/main.yaml +++ b/pkgs/development/haskell-modules/configuration-hackage2nix/main.yaml @@ -92,7 +92,6 @@ extra-packages: - hasql-transaction < 1.1.1 # 2025-01-19: Needed for building postgrest - hlint == 3.6.* # 2025-04-14: needed for hls with ghc-lib-parser 9.6 - hlint == 3.8.* # 2025-09-21: needed for hls with ghc-lib-parser 9.8 - - hpack == 0.38.1 # 2025-09-18: to match exact version upstream stack-3.7.1 uses - language-javascript == 0.7.0.0 # required by purescript - network-run == 0.4.0 # 2024-10-20: for GHC 9.10/network == 3.1.* - ormolu == 0.7.2.0 # 2023-11-13: for ghc-lib-parser 9.6 compat diff --git a/pkgs/development/haskell-modules/hackage-packages.nix b/pkgs/development/haskell-modules/hackage-packages.nix index 5ef131127bad..dd96b701e8df 100644 --- a/pkgs/development/haskell-modules/hackage-packages.nix +++ b/pkgs/development/haskell-modules/hackage-packages.nix @@ -346181,141 +346181,6 @@ self: { } ) { }; - hpack_0_38_1 = callPackage ( - { - mkDerivation, - aeson, - base, - bifunctors, - bytestring, - Cabal, - containers, - crypton, - deepseq, - directory, - filepath, - Glob, - hspec, - hspec-discover, - http-client, - http-client-tls, - http-types, - HUnit, - infer-license, - interpolate, - mockery, - mtl, - pretty, - QuickCheck, - scientific, - template-haskell, - temporary, - text, - transformers, - unordered-containers, - vcr, - vector, - yaml, - }: - mkDerivation { - pname = "hpack"; - version = "0.38.1"; - sha256 = "03qygb51jb4r6sg2bkaz7k80h11wgjr27hgpx6h08xm8axdk2gba"; - revision = "1"; - editedCabalFile = "0dyd6pp2pk62nynp0x2j9kjddfv43p9inplk4iya7hdldyjs77k0"; - isLibrary = true; - isExecutable = true; - libraryHaskellDepends = [ - aeson - base - bifunctors - bytestring - Cabal - containers - crypton - deepseq - directory - filepath - Glob - http-client - http-client-tls - http-types - infer-license - mtl - pretty - scientific - text - transformers - unordered-containers - vector - yaml - ]; - executableHaskellDepends = [ - aeson - base - bifunctors - bytestring - Cabal - containers - crypton - deepseq - directory - filepath - Glob - http-client - http-client-tls - http-types - infer-license - mtl - pretty - scientific - text - transformers - unordered-containers - vector - yaml - ]; - testHaskellDepends = [ - aeson - base - bifunctors - bytestring - Cabal - containers - crypton - deepseq - directory - filepath - Glob - hspec - http-client - http-client-tls - http-types - HUnit - infer-license - interpolate - mockery - mtl - pretty - QuickCheck - scientific - template-haskell - temporary - text - transformers - unordered-containers - vcr - vector - yaml - ]; - testToolDepends = [ hspec-discover ]; - description = "A modern format for Haskell packages"; - license = lib.licenses.mit; - hydraPlatforms = lib.platforms.none; - mainProgram = "hpack"; - } - ) { }; - hpack = callPackage ( { mkDerivation,