on iko/ghcjs-patch-master help sign in
Use mkmerge for the all component. [Fixes #42]
a7568a0Will Fancher
lib/default.nix+5−32
@@ -13,49 +13,22 @@ with haskellLib;
13 "benchmarks"
13 "benchmarks"
14 ];
14 ];
15
15
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−
40 foldrAttrVals = f: z: attrs:
16 foldrAttrVals = f: z: attrs:
41− lib.foldr (g: acc: g acc) z (lib.mapAttrsToList f attrs);
17+ lib.foldr (g: acc: g acc) z (lib.mapAttrsToList (_name: f) attrs);
42−
43− attrLength = attrs: builtins.length (builtins.attrValues attrs);
44
18
45 foldComponents = tys: f: z: conf:
19 foldComponents = tys: f: z: conf:
46 let
20 let
47 comps = conf.components or {};
21 comps = conf.components or {};
48− foldSection = foldrAttrVals f;
22+ libComp = acc: if comps ? library then f comps.library acc else acc;
49− libComp = acc:
50− foldSection acc
51− (removeAttrs comps subComponentTypes);
52 subComps = acc:
23 subComps = acc:
53 lib.foldr
24 lib.foldr
54− (ty: acc': foldSection acc' (comps.${ty} or {}))
25+ (ty: acc': foldrAttrVals f acc' (comps.${ty} or {}))
55 acc
26 acc
56 tys;
27 tys;
57 in libComp (subComps z);
28 in libComp (subComps z);
58
29
30+ getAllComponents = foldComponents subComponentTypes (c: acc: [c] ++ acc) [];
31+
59 componentPrefix = {
32 componentPrefix = {
60 # Are all of these right?
33 # Are all of these right?
61 sublibs = "sublib";
34 sublibs = "sublib";
modules/package.nix+6−14
@@ -13,14 +13,12 @@
13# tests = { "..." = { depends = ... }; ... };
13# tests = { "..." = { depends = ... }; ... };
14# };
14# };
15
15
16−{ lib, config, pkgs, ... }:
16+{ lib, config, pkgs, haskellLib, ... }:
17
17
18with lib;
18with lib;
19with types;
19with types;
20
20
21let
21let
22− haskellLib = let hl = import ../lib { inherit lib; haskellLib = hl; }; in hl;
23−
24 # This is just like listOf, except that it filters out all null elements.
22 # This is just like listOf, except that it filters out all null elements.
25 listOfFilteringNulls = elemType: listOf elemType // {
23 listOfFilteringNulls = elemType: listOf elemType // {
26 # Mostly copied from nixpkgs/lib/types.nix
24 # Mostly copied from nixpkgs/lib/types.nix
@@ -175,17 +173,9 @@ in {
175 type = attrsOf (componentType {});
173 type = attrsOf (componentType {});
176 default = {};
174 default = {};
177 };
175 };
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 {
176+ all = mkOption {
186− type = componentType default;
177+ type = componentType {};
187− inherit default;
188− defaultText = "The merged dependencies of all other components";
178+ description = "The merged dependencies of all other components";
189 };
179 };
190 };
180 };
191
181
@@ -289,4 +279,6 @@ in {
289 default = false;
279 default = false;
290 };
280 };
291 };
281 };
282+
283+ config.components.all = lib.mkMerge (haskellLib.getAllComponents config);
292}
284}
modules/plan.nix+2−2
@@ -10,7 +10,7 @@
10# packages = { "bytestring" = "a.b.c.d"; ... }; };
10# packages = { "bytestring" = "a.b.c.d"; ... }; };
11# }
11# }
12
12
13−{ lib, config, pkgs, pkgconfPkgs, ... }:
13+{ lib, config, pkgs, pkgconfPkgs, haskellLib, ... }:
14
14
15with lib;
15with lib;
16with types;
16with types;
@@ -21,7 +21,7 @@ with types;
21 type = attrsOf (submodule {
21 type = attrsOf (submodule {
22 imports = [./package.nix];
22 imports = [./package.nix];
23 _module.args = {
23 _module.args = {
24− inherit pkgs pkgconfPkgs;
24+ inherit pkgs pkgconfPkgs haskellLib;
25 inherit (config) hsPkgs;
25 inherit (config) hsPkgs;
26 inherit (config.cabal) system compiler;
26 inherit (config.cabal) system compiler;
27 };
27 };