@@ -19,6 +19,8 @@ with lib;
19
19
with types ;
20
20
21
21
let
22
+ haskellLib = let hl = import ../lib { inherit lib ; haskellLib = hl ; } ; in hl ;
23
+
22
24
# This is just like listOf, except that it filters out all null elements.
23
25
listOfFilteringNulls = elemType : listOf elemType // {
24
26
# Mostly copied from nixpkgs/lib/types.nix
97
99
} ;
98
100
99
101
components = let
100
- componentType = check : submodule {
102
+ componentType = defaults : submodule {
101
103
options = {
102
104
depends = mkOption {
103
105
type = listOfFilteringNulls unspecified ;
104
- default = [ ] ;
106
+ default = defaults . depends or [ ] ;
105
107
} ;
106
108
libs = mkOption {
107
109
type = listOfFilteringNulls ( nullOr package ) ;
141
143
} ;
142
144
doCheck = mkOption {
143
145
type = bool ;
144
- default = check ;
146
+ default = defaults . doCheck or false ;
145
147
} ;
146
148
doCrossCheck = mkOption {
147
149
type = bool ;
@@ -151,35 +153,38 @@ in {
151
153
} ;
152
154
in {
153
155
library = mkOption {
154
- type = componentType false ;
156
+ type = componentType { } ;
155
157
} ;
156
158
sublibs = mkOption {
157
- type = attrsOf ( componentType false ) ;
159
+ type = attrsOf ( componentType { } ) ;
158
160
default = { } ;
159
161
} ;
160
162
foreignlibs = mkOption {
161
- type = attrsOf ( componentType false ) ;
163
+ type = attrsOf ( componentType { } ) ;
162
164
default = { } ;
163
165
} ;
164
166
exes = mkOption {
165
- type = attrsOf ( componentType false ) ;
167
+ type = attrsOf ( componentType { } ) ;
166
168
default = { } ;
167
169
} ;
168
170
tests = mkOption {
169
- type = attrsOf ( componentType config . doCheck ) ;
171
+ type = attrsOf ( componentType { inherit ( config ) doCheck ; } ) ;
170
172
default = { } ;
171
173
} ;
172
174
benchmarks = mkOption {
173
- type = attrsOf ( componentType false ) ;
175
+ type = attrsOf ( componentType { } ) ;
174
176
default = { } ;
175
177
} ;
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 ;
182
184
} ;
185
+ in mkOption {
186
+ type = componentType default ;
187
+ inherit default ;
183
188
defaultText = "The merged dependencies of all other components" ;
184
189
} ;
185
190
} ;
0 commit comments