1{ lib, ... }:
2
3with lib;
4
5let
6 maintainer = mkOptionType {
7 name = "maintainer";
8 check = email: elem email (attrValues lib.maintainers);
9 merge = loc: defs: listToAttrs (singleton (nameValuePair (last defs).file (last defs).value));
10 };
11
12 listOfMaintainers = types.listOf maintainer // {
13 # Returns list of
14 # { "module-file" = [
15 # "maintainer1 <first@nixos.org>"
16 # "maintainer2 <second@nixos.org>" ];
17 # }
18 merge = loc: defs:
19 zipAttrs
20 (flatten (imap1 (n: def: imap1 (m: def':
21 maintainer.merge (loc ++ ["[${toString n}-${toString m}]"])
22 [{ inherit (def) file; value = def'; }]) def.value) defs));
23 };
24
25 docFile = types.path // {
26 # Returns tuples of
27 # { file = "module location"; value = <path/to/doc.xml>; }
28 merge = loc: defs: defs;
29 };
30in
31
32{
33 options = {
34 meta = {
35
36 maintainers = mkOption {
37 type = listOfMaintainers;
38 internal = true;
39 default = [];
40 example = literalExpression ''[ lib.maintainers.all ]'';
41 description = ''
42 List of maintainers of each module. This option should be defined at
43 most once per module.
44 '';
45 };
46
47 doc = mkOption {
48 type = docFile;
49 internal = true;
50 example = "./meta.chapter.md";
51 description = ''
52 Documentation prologue for the set of options of each module. This
53 option should be defined at most once per module.
54 '';
55 };
56
57 buildDocsInSandbox = mkOption {
58 type = types.bool // {
59 merge = loc: defs: defs;
60 };
61 internal = true;
62 default = true;
63 description = ''
64 Whether to include this module in the split options doc build.
65 Disable if the module references `config`, `pkgs` or other module
66 arguments that cannot be evaluated as constants.
67
68 This option should be defined at most once per module.
69 '';
70 };
71
72 };
73 };
74
75 meta.maintainers = singleton lib.maintainers.pierron;
76}