diff --git a/builder/make-config-files.nix b/builder/make-config-files.nix index 02722535..dfeda719 100644 --- a/builder/make-config-files.nix +++ b/builder/make-config-files.nix @@ -6,10 +6,29 @@ let echo "${field}: ${lib.concatStringsSep " " xs}" >> $out/cabal.config ''; + # This is a bit of a hack. So we'll have a slightly longer explaination here: + # exactDep will pass --exact-configuration to the `SETUP_HS confiugre` command. + # This requires us to pass --dependency={dep name}={pkg id}. The dependency + # name will usually be the name of the package `p`, which we can locate in the + # package-db, passed in via `pdbArg`. Thus querying the package-db for the + # id field for package `p`, will unsually provide is with the right value. Sublibs + # need a bit of special handling: + # + # - Sublibs: if the dependency is a sublibrary of a package, we need to use + # the sublibrary's name for the dep name, and lookup the sublibraries + # pkg id for z-{pkg name}-z-{sublib name}. As we do not provide the + # sublib name to exactDep, as we don't have access to it at the call-site, + # we resort to a bit of globbing, which (as pkg db's should contain only + # a single package) work. exactDep = pdbArg: p: '' if id=$(target-pkg ${pdbArg} field ${p} id --simple-output); then echo "--dependency=${p}=$id" >> $out/configure-flags - fi + elif id=$(target-pkg ${pdbArg} field "z-${p}-z-*" id --simple-output); then + name=$(target-pkg ${pdbArg} field "z-${p}-z-*" name --simple-output) + # so we are dealing with a sublib. As we build sublibs separately, the above + # query should be safe. + echo "--dependency=''${name#z-${p}-z-}=$id" >> $out/configure-flags + fi if ver=$(target-pkg ${pdbArg} field ${p} version --simple-output); then echo "constraint: ${p} == $ver" >> $out/cabal.config echo "constraint: ${p} installed" >> $out/cabal.config @@ -68,7 +87,7 @@ in { identifier, component, fullName, flags ? {} }: echo "allow-newer: ${identifier.name}:*" >> $out/cabal.config echo "allow-older: ${identifier.name}:*" >> $out/cabal.config - ${lib.concatMapStringsSep "\n" (p: exactDep "--package-db ${p.components.library}/package.conf.d" p.identifier.name) component.depends} + ${lib.concatMapStringsSep "\n" (p: exactDep "--package-db ${p.components.library or p}/package.conf.d" p.identifier.name) component.depends} ${lib.concatMapStringsSep "\n" (exactDep "") nonReinstallablePkgs} '' diff --git a/default.nix b/default.nix index 03abe1bf..0b744172 100644 --- a/default.nix +++ b/default.nix @@ -104,7 +104,9 @@ let in self.mkPkgSet { inherit pkg-def; pkg-def-extras = [ stack-pkgs.extras ] ++ pkg-def-extras; - modules = [ patchesModule ] ++ modules; + # set doExactConfig = true. The stackage set should be consistent + # and we should trust stackage here! + modules = [ { doExactConfig = true; } patchesModule ] ++ modules; }; # Create a Haskell package set based on a Cabal configuration. @@ -122,7 +124,9 @@ let in self.mkPkgSet { inherit pkg-def; pkg-def-extras = [ plan-pkgs.extras ] ++ pkg-def-extras; - modules = [ patchesModule ] ++ modules; + # set doExactConfig = true, as we trust cabals resolution for + # the plan. + modules = [ { doExactConfig = true; } patchesModule ] ++ modules; }; # Package sets for all stackage snapshots. diff --git a/modules/component-driver.nix b/modules/component-driver.nix index 80cdc94b..54f877ac 100644 --- a/modules/component-driver.nix +++ b/modules/component-driver.nix @@ -13,8 +13,13 @@ in options.nonReinstallablePkgs = lib.mkOption { type = lib.types.listOf lib.types.str; }; + options.reinstallableLibGhc = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Is lib:ghc reinstallable?"; + }; - # Dependencies + # Dependencies (with reinstallable-lib:ghc) # # .--------. .------------------. # | pretty | < ------- | template-haskell | @@ -31,10 +36,13 @@ in # | .-----. | '-- > |-------or-------| # '---- > | rts | < -----' | integer-gmp | # '-----' '----------------' + # + # without reinstallable-lib:ghc, this is significantly larger. config.nonReinstallablePkgs = [ "rts" "ghc-heap" "ghc-prim" "integer-gmp" "integer-simple" "base" - "deepseq" "array" "ghc-boot-th" "pretty" "template-haskell" ]; + "deepseq" "array" "ghc-boot-th" "pretty" "template-haskell" ] + ++ lib.optional (!config.reinstallableLibGhc) "ghc"; options.hsPkgs = lib.mkOption { type = lib.types.unspecified;