on iko/ghcjs-patch-master help sign in
Better defaults (doExactConfig = true; non-reinstallable lib:ghc) (#206)

* Better defaults (doExactConfig = true; non-reinstallable lib:ghc) Disabling haddocks by default has unintended consequences, as such we'll wait for the `.doc` derivation to solve this. Fixes #201, #191

commit8a3489e1dc71fcbc5486ce82bed96f65156a50ef authorMoritz Angermann <moritz.angermann@gmail.com> dateTue 16 Jul 2019, 15:14 (7 years ago) parentdedb91e
3 files changed+37−6
builder/make-config-files.nix+21−2 default.nix+6−2 modules/component-driver.nix+10−2
builder/make-config-files.nix+21−2
@@ -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 ''
default.nix+6−2
@@ -104,7 +104,9 @@ let
104104 in self.mkPkgSet {
105105 inherit pkg-def;
106106 pkg-def-extras = [ stack-pkgs.extras ] ++ pkg-def-extras;
107− modules = [ patchesModule ] ++ modules;
107+ # set doExactConfig = true. The stackage set should be consistent
108+ # and we should trust stackage here!
109+ modules = [ { doExactConfig = true; } patchesModule ] ++ modules;
108110 };
109111
110112 # Create a Haskell package set based on a Cabal configuration.
@@ -122,7 +124,9 @@ let
122124 in self.mkPkgSet {
123125 inherit pkg-def;
124126 pkg-def-extras = [ plan-pkgs.extras ] ++ pkg-def-extras;
125− modules = [ patchesModule ] ++ modules;
127+ # set doExactConfig = true, as we trust cabals resolution for
128+ # the plan.
129+ modules = [ { doExactConfig = true; } patchesModule ] ++ modules;
126130 };
127131
128132 # Package sets for all stackage snapshots.
modules/component-driver.nix+10−2
@@ -13,8 +13,13 @@ in
1313 options.nonReinstallablePkgs = lib.mkOption {
1414 type = lib.types.listOf lib.types.str;
1515 };
16+ options.reinstallableLibGhc = lib.mkOption {
17+ type = lib.types.bool;
18+ default = false;
19+ description = "Is lib:ghc reinstallable?";
20+ };
1621
17− # Dependencies
22+ # Dependencies (with reinstallable-lib:ghc)
1823 #
1924 # .--------. .------------------.
2025 # | pretty | < ------- | template-haskell |
@@ -31,10 +36,13 @@ in
3136 # | .-----. | '-- > |-------or-------|
3237 # '---- > | rts | < -----' | integer-gmp |
3338 # '-----' '----------------'
39+ #
40+ # without reinstallable-lib:ghc, this is significantly larger.
3441
3542 config.nonReinstallablePkgs =
3643 [ "rts" "ghc-heap" "ghc-prim" "integer-gmp" "integer-simple" "base"
37− "deepseq" "array" "ghc-boot-th" "pretty" "template-haskell" ];
44+ "deepseq" "array" "ghc-boot-th" "pretty" "template-haskell" ]
45+ ++ lib.optional (!config.reinstallableLibGhc) "ghc";
3846
3947 options.hsPkgs = lib.mkOption {
4048 type = lib.types.unspecified;