@@ -6,10 +6,29 @@ let
66 echo "${field}: ${lib.concatStringsSep " " xs}" >> $out/cabal.config
77 '';
88
9+ # This is a bit of a hack. So we'll have a slightly longer explaination here:
10+ # exactDep will pass --exact-configuration to the `SETUP_HS confiugre` command.
11+ # This requires us to pass --dependency={dep name}={pkg id}. The dependency
12+ # name will usually be the name of the package `p`, which we can locate in the
13+ # package-db, passed in via `pdbArg`. Thus querying the package-db for the
14+ # id field for package `p`, will unsually provide is with the right value. Sublibs
15+ # need a bit of special handling:
16+ #
17+ # - Sublibs: if the dependency is a sublibrary of a package, we need to use
18+ # the sublibrary's name for the dep name, and lookup the sublibraries
19+ # pkg id for z-{pkg name}-z-{sublib name}. As we do not provide the
20+ # sublib name to exactDep, as we don't have access to it at the call-site,
21+ # we resort to a bit of globbing, which (as pkg db's should contain only
22+ # a single package) work.
923 exactDep = pdbArg: p: ''
1024 if id=$(target-pkg ${pdbArg} field ${p} id --simple-output); then
1125 echo "--dependency=${p}=$id" >> $out/configure-flags
12− fi
26+ elif id=$(target-pkg ${pdbArg} field "z-${p}-z-*" id --simple-output); then
27+ name=$(target-pkg ${pdbArg} field "z-${p}-z-*" name --simple-output)
28+ # so we are dealing with a sublib. As we build sublibs separately, the above
29+ # query should be safe.
30+ echo "--dependency=''${name#z-${p}-z-}=$id" >> $out/configure-flags
31+ fi
1332 if ver=$(target-pkg ${pdbArg} field ${p} version --simple-output); then
1433 echo "constraint: ${p} == $ver" >> $out/cabal.config
1534 echo "constraint: ${p} installed" >> $out/cabal.config
@@ -68,7 +87,7 @@ in { identifier, component, fullName, flags ? {} }:
6887 echo "allow-newer: ${identifier.name}:*" >> $out/cabal.config
6988 echo "allow-older: ${identifier.name}:*" >> $out/cabal.config
7089
71− ${lib.concatMapStringsSep "\n" (p: exactDep "--package-db ${p.components.library}/package.conf.d" p.identifier.name) component.depends}
90+ ${lib.concatMapStringsSep "\n" (p: exactDep "--package-db ${p.components.library or p}/package.conf.d" p.identifier.name) component.depends}
7291 ${lib.concatMapStringsSep "\n" (exactDep "") nonReinstallablePkgs}
7392
7493 ''