-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.nix
77 lines (54 loc) · 1.79 KB
/
options.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{ lib }: let
# See: https://ryantm.github.io/nixpkgs/functions/library/options/#sec-functions-library-options
inherit (lib) mkOption types;
in {
# Shorthand for creating string options in custom modules.
mkStrOption = default: description: (
mkOption {
inherit default description;
type = types.str;
}
);
# Shorthand for creating string lists options in custom modules.
mkStrListOption = default: description: (
mkOption {
inherit default description;
type = types.listOf types.str;
}
);
# Shorthand for creating submodule options in custom modules.
mkSubmoduleOption = default: description: submodule: (
mkOption {
inherit default description;
type = types.submodule { options = submodule; };
}
);
# Shorthand for creating submodule options in custom modules.
mkSubmoduleWithConfigOption = default: description: submodule: config: (
mkOption {
inherit default description;
type = types.submodule { inherit config; options = submodule; };
}
);
# Shorthand for creating submodule lists options in custom modules.
mkSubmoduleListOption = default: description: submodule: (
mkOption {
inherit default description;
type = types.listOf (types.submodule { options = submodule; });
}
);
# Shorthand for creating dynamic submodules in custom modules. (ex: my.module.<anything here>)
mkDynamicAttrsetOption = default: description: mkSubmodule: (
mkOption {
inherit default description;
type = types.attrsOf (types.submodule mkSubmodule);
}
);
# Shorthand for creating package lists options in custom modules.
mkPackageListOption = default: description: (
mkOption {
inherit default description;
type = types.listOf types.package;
}
);
}