@@ -13,39 +13,22 @@
1313# tests = { "..." = { depends = ... }; ... };
1414# };
1515
16+{ parentConfig, mod_args, listOfFilteringNulls, componentOptions, packageOptions }:
1617{ lib, config, pkgs, haskellLib, ... }:
1718
1819with lib;
1920with types;
2021
21−let
22− # This is just like listOf, except that it filters out all null elements.
23− listOfFilteringNulls = elemType: listOf elemType // {
24− # Mostly copied from nixpkgs/lib/types.nix
25− merge = loc: defs:
26− map (x: x.value) (filter (x: x ? value && x.value != null) (concatLists (imap1 (n: def:
27− if isList def.value then
28− imap1 (m: def':
29− (mergeDefinitions
30− (loc ++ ["[definition ${toString n}-entry ${toString m}]"])
31− elemType
32− [{ inherit (def) file; value = def'; }]
33− ).optionalValue
34− ) def.value
35− else
36− throw "The option value `${showOption loc}` in `${def.file}` is not a list.") defs)));
37− };
38−in {
22+{
3923 # This is how the Nix expressions generated by *-to-nix receive
4024 # their flags argument.
41− config._module.args.flags = config.flags;
25+ config._module.args = mod_args // { flags = config.flags; };
4226
43− options = {
27+ options = (packageOptions parentConfig) // {
4428 # TODO: Add descriptions to everything.
4529 flags = mkOption {
4630 type = attrsOf bool;
4731 };
48−
4932 package = {
5033 specVersion = mkOption {
5134 type = str;
@@ -98,7 +81,8 @@ in {
9881
9982 components = let
10083 componentType = submodule {
101− options = {
84+ # add the shared componentOptions
85+ options = (componentOptions config) // {
10286 depends = mkOption {
10387 type = listOfFilteringNulls unspecified;
10488 default = [];
@@ -119,43 +103,6 @@ in {
119103 type = listOfFilteringNulls unspecified;
120104 default = [];
121105 };
122− configureFlags = mkOption {
123− type = listOfFilteringNulls str;
124− default = config.configureFlags;
125− };
126− setupBuildFlags = mkOption {
127− type = listOfFilteringNulls str;
128− default = config.setupBuildFlags;
129− };
130− setupTestFlags = mkOption {
131− type = listOfFilteringNulls str;
132− default = config.setupTestFlags;
133− };
134− setupInstallFlags = mkOption {
135− type = listOfFilteringNulls str;
136− default = config.setupInstallFlags;
137− };
138− setupHaddockFlags = mkOption {
139− type = listOfFilteringNulls str;
140− default = config.setupHaddockFlags;
141− };
142− doExactConfig = mkOption {
143− type = bool;
144− default = config.doExactConfig;
145− };
146− doCheck = mkOption {
147− type = bool;
148− default = config.doCheck;
149− };
150− doCrossCheck = mkOption {
151− type = bool;
152− default = config.doCrossCheck;
153− };
154− doHaddock = mkOption {
155− description = "Enable building of the Haddock documentation from the annotated Haskell source code.";
156− type = bool;
157− default = config.doHaddock;
158− };
159106 };
160107 };
161108 in {
@@ -224,96 +171,6 @@ in {
224171 type = listOf (either unspecified path);
225172 default = [];
226173 };
227− configureFlags = mkOption {
228− type = listOfFilteringNulls str;
229− default = [];
230− };
231− setupBuildFlags = mkOption {
232− type = listOfFilteringNulls str;
233− default = [];
234− };
235− setupTestFlags = mkOption {
236− type = listOfFilteringNulls str;
237− default = [];
238− };
239− setupInstallFlags = mkOption {
240− type = listOfFilteringNulls str;
241− default = [];
242− };
243− setupHaddockFlags = mkOption {
244− type = listOfFilteringNulls str;
245− default = [];
246− };
247− preUnpack = mkOption {
248− type = nullOr lines;
249− default = null;
250− };
251− postUnpack = mkOption {
252− type = nullOr string;
253− default = null;
254− };
255− preConfigure = mkOption {
256− type = nullOr string;
257− default = null;
258− };
259− postConfigure = mkOption {
260− type = nullOr string;
261− default = null;
262− };
263− preBuild = mkOption {
264− type = nullOr string;
265− default = null;
266− };
267− postBuild = mkOption {
268− type = nullOr string;
269− default = null;
270− };
271− preCheck = mkOption {
272− type = nullOr string;
273− default = null;
274− };
275− postCheck = mkOption {
276− type = nullOr string;
277− default = null;
278− };
279− preInstall = mkOption {
280− type = nullOr string;
281− default = null;
282− };
283− postInstall = mkOption {
284− type = nullOr string;
285− default = null;
286− };
287− preHaddock = mkOption {
288− type = nullOr string;
289− default = null;
290− };
291− postHaddock = mkOption {
292− type = nullOr string;
293− default = null;
294− };
295− shellHook = mkOption {
296− type = nullOr string;
297− default = null;
298− };
299− doExactConfig = mkOption {
300− type = bool;
301− default = false;
302− };
303− doCheck = mkOption {
304− type = bool;
305− default = false;
306− };
307− doCrossCheck = mkOption {
308− description = "Run doCheck also in cross compilation settings. This can be tricky as the test logic must know how to run the tests on the target.";
309− type = bool;
310− default = false;
311− };
312− doHaddock = mkOption {
313− description = "Enable building of the Haddock documentation from the annotated Haskell source code.";
314− type = bool;
315− default = true;
316− };
317174 };
318175
319176 # This has one quirk. Manually setting options on the all component