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:19:25 +0200
committersternenseemann <sternenseemann@systemli.org>2023-08-08 11:57:37 +0200
commit88f20627977e430e5ccbdebb8e36550c7ea55fe3 (patch)
treeb93f6af0377e39bbaaa8b69420cc5f3ea8545200 /pkgs/development/haskell-modules/generic-builder.nix
parent305246161f2273f1eecb9834dc6522bf2fe310d4 (diff)
downloadnixpkgs-88f20627977e430e5ccbdebb8e36550c7ea55fe3.tar
nixpkgs-88f20627977e430e5ccbdebb8e36550c7ea55fe3.tar.gz
nixpkgs-88f20627977e430e5ccbdebb8e36550c7ea55fe3.tar.bz2
nixpkgs-88f20627977e430e5ccbdebb8e36550c7ea55fe3.tar.lz
nixpkgs-88f20627977e430e5ccbdebb8e36550c7ea55fe3.tar.xz
nixpkgs-88f20627977e430e5ccbdebb8e36550c7ea55fe3.tar.zst
nixpkgs-88f20627977e430e5ccbdebb8e36550c7ea55fe3.zip
haskellPackages.mkDerivation: opt to only propagate pkgConfigModules
The main idea is to limit the amount of flags passed to Setup.hs as well
as, consequently, linkers and C compilers. E.g. in the case of
gi-javascriptcore, the default behavior causes the argv limit to be
exceeded.
Diffstat (limited to 'pkgs/development/haskell-modules/generic-builder.nix')
-rw-r--r--pkgs/development/haskell-modules/generic-builder.nix24
1 files changed, 20 insertions, 4 deletions
diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix
index e47a0ecfa63..960dbf64d40 100644
--- a/pkgs/development/haskell-modules/generic-builder.nix
+++ b/pkgs/development/haskell-modules/generic-builder.nix
@@ -98,6 +98,15 @@ 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.
+  __onlyPropagateKnownPkgConfigModules ? false
 } @ args:
 
 assert editedCabalFile != null -> revision != null;
@@ -265,6 +274,13 @@ let
   # pkg-config --static to work in most cases.
   allPkgconfigDepends =
     let
+      # If __onlyPropagateKnownPkgConfigModules is set, packages without
+      # meta.pkgConfigModules will be filtered out, otherwise all packages in
+      # buildInputs and propagatePlainBuildInputs are propagated.
+      propagateValue = drv:
+        lib.isDerivation drv
+        && (__onlyPropagateKnownPkgConfigModules -> drv ? meta.pkgConfigModules);
+
       # Take list of derivations and return list of the transitive dependency
       # closure, only taking into account buildInputs. Loosely based on
       # closePropagationFast.
@@ -273,12 +289,12 @@ let
           builtins.genericClosure {
             startSet = builtins.map (drv:
               { key = drv.outPath; val = drv; }
-            ) (builtins.filter lib.isDerivation drvs);
+            ) (builtins.filter propagateValue drvs);
             operator = { val, ... }:
               builtins.concatMap (drv:
-                if !lib.isDerivation drv
-                then [ ]
-                else [ { key = drv.outPath; val = drv; } ]
+                if propagateValue drv
+                then [ { key = drv.outPath; val = drv; } ]
+                else [ ]
               ) (val.buildInputs or [ ] ++ val.propagatedBuildInputs or [ ]);
           }
         );