@@ -19,6 +19,8 @@ with lib;
1919with types;
2020
2121let
22+ haskellLib = let hl = import ../lib { inherit lib; haskellLib = hl; }; in hl;
23+
2224 # This is just like listOf, except that it filters out all null elements.
2325 listOfFilteringNulls = elemType: listOf elemType // {
2426 # Mostly copied from nixpkgs/lib/types.nix
@@ -97,11 +99,11 @@ in {
9799 };
98100
99101 components = let
100− componentType = check: submodule {
102+ componentType = defaults: submodule {
101103 options = {
102104 depends = mkOption {
103105 type = listOfFilteringNulls unspecified;
104− default = [];
106+ default = defaults.depends or [];
105107 };
106108 libs = mkOption {
107109 type = listOfFilteringNulls (nullOr package);
@@ -141,7 +143,7 @@ in {
141143 };
142144 doCheck = mkOption {
143145 type = bool;
144− default = check;
146+ default = defaults.doCheck or false;
145147 };
146148 doCrossCheck = mkOption {
147149 type = bool;
@@ -151,35 +153,38 @@ in {
151153 };
152154 in {
153155 library = mkOption {
154− type = componentType false;
156+ type = componentType {};
155157 };
156158 sublibs = mkOption {
157− type = attrsOf (componentType false);
159+ type = attrsOf (componentType {});
158160 default = {};
159161 };
160162 foreignlibs = mkOption {
161− type = attrsOf (componentType false);
163+ type = attrsOf (componentType {});
162164 default = {};
163165 };
164166 exes = mkOption {
165− type = attrsOf (componentType false);
167+ type = attrsOf (componentType {});
166168 default = {};
167169 };
168170 tests = mkOption {
169− type = attrsOf (componentType config.doCheck);
171+ type = attrsOf (componentType { inherit (config) doCheck; });
170172 default = {};
171173 };
172174 benchmarks = mkOption {
173− type = attrsOf (componentType false);
175+ type = attrsOf (componentType {});
174176 default = {};
175177 };
176− all = mkOption {
177− type = componentType false;
178− default = let
179− componentTypes = [ "library" "sublibs" "foreignlibs" "exes" "tests" "benchmarks" ];
180− in {
181− depends = mkMerge (map (c: config.components.${c}.depends or []) componentTypes);
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;
182184 };
185+ in mkOption {
186+ type = componentType default;
187+ inherit default;
183188 defaultText = "The merged dependencies of all other components";
184189 };
185190 };