on iko/ghcjs-patch-master help sign in
Use mkmerge for the all component. [Fixes #42]
commita7568a0e77c49a49c5a9763def7e0fbb61f87d8d authorWill Fancher <elvishjerricco@gmail.com> dateFri 1 Feb 2019, 23:23 (8 years ago) parent3451172
3 files changed+13−48
lib/default.nix+5−32 modules/package.nix+6−14 modules/plan.nix+2−2
lib/default.nix+5−32
@@ -13,49 +13,22 @@ with haskellLib;
1313 "benchmarks"
1414 ];
1515
16− mergeComponents = lib.zipAttrsWith (_: comps: lib.genAttrs [
17− "depends"
18− "libs"
19− "frameworks"
20− "pkgconfig"
21− "build-tools"
22− ] (n: {
23− ${n} = lib.concatMap (comp: comp.${n} or []) comps;
24− }));
25−
26− unionrAttrs = lib.foldr (a: b: a // b) {};
27−
28− mergeConfigs = configs:
29− let
30− mergeComponentType = type: mergeComponents (map (conf: (conf.components or {}).${type} or {}) configs);
31− in unionrAttrs configs // {
32− flags = unionrAttrs (map (conf: conf.flags or {}) configs);
33− package = lib.foldr (conf: lib.recursiveUpdate (conf.package or {})) {} configs;
34− components =
35− mergeComponents (map (conf: removeAttrs (conf.components or {}) subComponentTypes) configs)
36− // lib.genAttrs subComponentTypes mergeComponentType;
37− configureFlags = concatMap (conf: conf.configureFlags or []) configs;
38− };
39−
4016 foldrAttrVals = f: z: attrs:
41− lib.foldr (g: acc: g acc) z (lib.mapAttrsToList f attrs);
42−
43− attrLength = attrs: builtins.length (builtins.attrValues attrs);
17+ lib.foldr (g: acc: g acc) z (lib.mapAttrsToList (_name: f) attrs);
4418
4519 foldComponents = tys: f: z: conf:
4620 let
4721 comps = conf.components or {};
48− foldSection = foldrAttrVals f;
49− libComp = acc:
50− foldSection acc
51− (removeAttrs comps subComponentTypes);
22+ libComp = acc: if comps ? library then f comps.library acc else acc;
5223 subComps = acc:
5324 lib.foldr
54− (ty: acc': foldSection acc' (comps.${ty} or {}))
25+ (ty: acc': foldrAttrVals f acc' (comps.${ty} or {}))
5526 acc
5627 tys;
5728 in libComp (subComps z);
5829
30+ getAllComponents = foldComponents subComponentTypes (c: acc: [c] ++ acc) [];
31+
5932 componentPrefix = {
6033 # Are all of these right?
6134 sublibs = "sublib";
modules/package.nix+6−14
@@ -13,14 +13,12 @@
1313# tests = { "..." = { depends = ... }; ... };
1414# };
1515
16−{ lib, config, pkgs, ... }:
16+{ lib, config, pkgs, haskellLib, ... }:
1717
1818with lib;
1919with types;
2020
2121let
22− haskellLib = let hl = import ../lib { inherit lib; haskellLib = hl; }; in hl;
23−
2422 # This is just like listOf, except that it filters out all null elements.
2523 listOfFilteringNulls = elemType: listOf elemType // {
2624 # Mostly copied from nixpkgs/lib/types.nix
@@ -175,17 +173,9 @@ in {
175173 type = attrsOf (componentType {});
176174 default = {};
177175 };
178− all = let
179− subComponentsDepends = sub: concatLists
180− (mapAttrsToList (_: c: c.depends or []) config.components.${sub} or {});
181− default = {
182− depends = config.components.library.depends ++
183− concatMap subComponentsDepends haskellLib.subComponentTypes;
184− };
185− in mkOption {
186− type = componentType default;
187− inherit default;
188− defaultText = "The merged dependencies of all other components";
176+ all = mkOption {
177+ type = componentType {};
178+ description = "The merged dependencies of all other components";
189179 };
190180 };
191181
@@ -289,4 +279,6 @@ in {
289279 default = false;
290280 };
291281 };
282+
283+ config.components.all = lib.mkMerge (haskellLib.getAllComponents config);
292284}
modules/plan.nix+2−2
@@ -10,7 +10,7 @@
1010# packages = { "bytestring" = "a.b.c.d"; ... }; };
1111# }
1212
13−{ lib, config, pkgs, pkgconfPkgs, ... }:
13+{ lib, config, pkgs, pkgconfPkgs, haskellLib, ... }:
1414
1515with lib;
1616with types;
@@ -21,7 +21,7 @@ with types;
2121 type = attrsOf (submodule {
2222 imports = [./package.nix];
2323 _module.args = {
24− inherit pkgs pkgconfPkgs;
24+ inherit pkgs pkgconfPkgs haskellLib;
2525 inherit (config) hsPkgs;
2626 inherit (config.cabal) system compiler;
2727 };