summary refs log tree commit diff
path: root/pkgs/development/haskell-modules/generic-builder.nix
diff options
context:
space:
mode:
authorsternenseemann <sternenseemann@systemli.org>2023-08-07 17:29:30 +0200
committersternenseemann <sternenseemann@systemli.org>2023-08-08 11:57:37 +0200
commit2e876061cca520e8c1c1ade93e332ec685bf745f (patch)
tree4ad2aee38e0845707c89b80c4d342629fdd89cf5 /pkgs/development/haskell-modules/generic-builder.nix
parent88f20627977e430e5ccbdebb8e36550c7ea55fe3 (diff)
downloadnixpkgs-2e876061cca520e8c1c1ade93e332ec685bf745f.tar
nixpkgs-2e876061cca520e8c1c1ade93e332ec685bf745f.tar.gz
nixpkgs-2e876061cca520e8c1c1ade93e332ec685bf745f.tar.bz2
nixpkgs-2e876061cca520e8c1c1ade93e332ec685bf745f.tar.lz
nixpkgs-2e876061cca520e8c1c1ade93e332ec685bf745f.tar.xz
nixpkgs-2e876061cca520e8c1c1ade93e332ec685bf745f.tar.zst
nixpkgs-2e876061cca520e8c1c1ade93e332ec685bf745f.zip
haskellPackages.mkDerivation: allow overriding automatic propagation
Since we can't reliably (or easily at least) tell what Cabal version is
used, we should allow overriding whether to propagate or not, although
GHC >= 9.3 is correct in most cases.
Diffstat (limited to 'pkgs/development/haskell-modules/generic-builder.nix')
-rw-r--r--pkgs/development/haskell-modules/generic-builder.nix25
1 files changed, 16 insertions, 9 deletions
diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix
index 960dbf64d40..7001e4220ba 100644
--- a/pkgs/development/haskell-modules/generic-builder.nix
+++ b/pkgs/development/haskell-modules/generic-builder.nix
@@ -98,14 +98,21 @@ in
   # build products from that prior build as a starting point for accelerating
   # this build
 , previousIntermediates ? null
-, # For GHC >= 9.4 we currently automatically propagate the dependencies of
-  # allPkgconfigDepends to be direct dependencies to allow Cabal >= 3.8
-  # to call `pkg-config --libs --static` (https://github.com/haskell/cabal/issues/8455).
-  # This can easily lead to the argv limit being exceeded in linker or C compiler
-  # invocations. To work around this we can only propagate derivations that are
-  # known to provide pkg-config modules, as indicated by the presence of
-  # `meta.pkgConfigModules`. This option defaults to false for now, since this
-  # metadata is far from complete in nixpkgs.
+, # Cabal 3.8 which is shipped by default for GHC >= 9.3 always calls
+  # `pkg-config --libs --static` as part of the configure step. This requires
+  # Requires.private dependencies of pkg-config dependencies to be present in
+  # PKG_CONFIG_PATH which is normally not the case in nixpkgs (except in pkgsStatic).
+  # Since there is no patch or upstream patch yet, we replicate the automatic
+  # propagation of dependencies in pkgsStatic for allPkgConfigDepends for
+  # GHC >= 9.3 by default. This option allows overriding this behavior manually
+  # if mismatching Cabal and GHC versions are used.
+  # See also <https://github.com/haskell/cabal/issues/8455>.
+  __propagatePkgConfigDepends ? lib.versionAtLeast ghc.version "9.3"
+, # Propagation can easily lead to the argv limit being exceeded in linker or C
+  # compiler invocations. To work around this we can only propagate derivations
+  # that are known to provide pkg-config modules, as indicated by the presence
+  # of `meta.pkgConfigModules`. This option defaults to false for now, since
+  # this metadata is far from complete in nixpkgs.
   __onlyPropagateKnownPkgConfigModules ? false
 } @ args:
 
@@ -300,7 +307,7 @@ let
         );
     in
 
-    if lib.versionAtLeast ghc.version "9.3"
+    if __propagatePkgConfigDepends
     then propagatePlainBuildInputs allPkgconfigDepends'
     else allPkgconfigDepends';
   allPkgconfigDepends' =