|
6 | 6 | echo "${field}: ${lib.concatStringsSep " " xs}" >> $out/cabal.config |
7 | 7 | ''; |
8 | 8 |
|
| 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. |
9 | 23 | exactDep = pdbArg: p: '' |
10 | 24 | if id=$(target-pkg ${pdbArg} field ${p} id --simple-output); then |
11 | 25 | 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 |
13 | 32 | if ver=$(target-pkg ${pdbArg} field ${p} version --simple-output); then |
14 | 33 | echo "constraint: ${p} == $ver" >> $out/cabal.config |
15 | 34 | echo "constraint: ${p} installed" >> $out/cabal.config |
@@ -68,7 +87,7 @@ in { identifier, component, fullName, flags ? {} }: |
68 | 87 | echo "allow-newer: ${identifier.name}:*" >> $out/cabal.config |
69 | 88 | echo "allow-older: ${identifier.name}:*" >> $out/cabal.config |
70 | 89 |
|
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} |
72 | 91 | ${lib.concatMapStringsSep "\n" (exactDep "") nonReinstallablePkgs} |
73 | 92 |
|
74 | 93 | '' |
|
0 commit comments