Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions builder/make-config-files.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}

''
Expand Down
8 changes: 6 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
12 changes: 10 additions & 2 deletions modules/component-driver.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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;
Expand Down