@@ -1,4 +1,4 @@
1−{ stdenv, ghc, lib, pkgconfig, writeText, runCommand, haskellLib }:
1+{ stdenv, ghc, lib, pkgconfig, writeText, runCommand, haskellLib, nonReinstallablePkgs }:
22
33{ componentId
44, component
@@ -27,7 +27,14 @@ let
2727 };
2828 in map ({val,...}: val) closure;
2929
30− configFiles = runCommand "${fullName}-config" { nativeBuildInputs = [ghc]; } ''
30+ exactDep = pdbArg: p: ''
31+ if id=$(ghc-pkg ${pdbArg} field ${p} id --simple-output); then
32+ echo "--dependency=${p}=$id" >> $out/configure-flags
33+ # TODO: Figure out how to do this for cabal.config for nix-shell
34+ fi
35+ '';
36+
37+ configFiles = runCommand "${fullName}-config" { nativeBuildInputs = [ghc]; } (''
3138 mkdir -p $out
3239 ghc-pkg init $out/package.conf.d
3340
@@ -44,8 +51,16 @@ let
4451
4552 echo ${lib.concatStringsSep " " (lib.mapAttrsToList (fname: val: "--flags=${lib.optionalString (!val) "-" + fname}") flags)} >> $out/configure-flags
4653
54+ '' + lib.optionalString component.doExactConfig ''
55+ echo "--exact-configuration" >> $out/configure-flags
56+ echo "exact-configuration: True" >> $out/cabal.config
57+
58+ ${lib.concatMapStringsSep "\n" (p: exactDep "--package-db ${p.components.library}/package.conf.d" p.identifier.name) component.depends}
59+ ${lib.concatMapStringsSep "\n" (exactDep "") nonReinstallablePkgs}
60+
61+ '' + ''
4762 ghc-pkg --package-db $out/package.conf.d check
48− '';
63+ '');
4964
5065 finalConfigureFlags = lib.concatStringsSep " " (
5166 [ "--prefix=$out" "${componentId.ctype}:${componentId.cname}" ]