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