From eb4dcd05a562702824d87a671d255ad917d1caa6 Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Tue, 10 Mar 2026 23:04:51 +0100 Subject: [PATCH] haskellPackages.{cabal-add,fourmolu}: don't unnecessarily add prog to PATH cabal-add and fourmolu (ab)use build-tool-depends in order to have the package's executable in PATH during test suite _execution_. This feature was introduced in Cabal 3.14, so we can stop modifying PATH for GHC >= 9.12. --- .../haskell-modules/configuration-nix.nix | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/pkgs/development/haskell-modules/configuration-nix.nix b/pkgs/development/haskell-modules/configuration-nix.nix index cb6cd01b488b..faf97a886547 100644 --- a/pkgs/development/haskell-modules/configuration-nix.nix +++ b/pkgs/development/haskell-modules/configuration-nix.nix @@ -56,10 +56,18 @@ builtins.intersectAttrs super { ### HASKELL-LANGUAGE-SERVER SECTION ### ####################################### - cabal-add = overrideCabal (drv: { - # tests depend on executable - preCheck = ''export PATH="$PWD/dist/build/cabal-add:$PATH"''; - }) super.cabal-add; + cabal-add = + # Can't find executable without https://github.com/haskell/cabal/pull/9912 + if lib.versionOlder self.ghc.version "9.12" then + overrideCabal (drv: { + # tests depend on executable + preCheck = '' + ${drv.preCheck or ""} + export PATH="$PWD/dist/build/cabal-add:$PATH" + ''; + }) super.cabal-add + else + super.cabal-add; haskell-language-server = overrideCabal (drv: { # starting with 1.6.1.1 haskell-language-server wants to be linked dynamically @@ -1817,11 +1825,16 @@ builtins.intersectAttrs super { inherit ( let - fourmoluTestFix = overrideCabal (drv: { - preCheck = drv.preCheck or "" + '' - export PATH="$PWD/dist/build/fourmolu:$PATH" - ''; - }); + fourmoluTestFix = + # Can't find executable without https://github.com/haskell/cabal/pull/9912 + if lib.versionOlder self.ghc.version "9.12" then + overrideCabal (drv: { + preCheck = drv.preCheck or "" + '' + export PATH="$PWD/dist/build/fourmolu:$PATH" + ''; + }) + else + lib.id; in builtins.mapAttrs (_: fourmoluTestFix) super )