blob: f76ccfeb24c8f1c10df7b4a871a1875eb34a622b (
plain)
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
|
{
# The first few arguments are implicitly passed by the 'close' helper
lib,
pkgs,
doctrine,
name,
config,
hm ? null,
sys ? null,
options ? null,
requires ? [],
prefix ? doctrine.prefix,
namespace ? doctrine.namespace,
}: let
optionsSet = import options {
inherit config lib pkgs cfg name doctrine;
};
configSet = import configFiles.${namespace} {
inherit config lib pkgs doctrine cfg;
};
configFiles = lib.filterAttrs (k: v: v != null) {
inherit sys hm;
};
cfg = config.${prefix}.${name};
in {
config =
lib.optionalAttrs (configFiles ? ${namespace})
(lib.mkIf cfg.enable (lib.mkMerge [
configSet
{
assertions =
map (dependency: {
assertion = cfg.enable -> config.${prefix}.${dependency}.enable;
message = "${prefix}.${name}.enable requires ${prefix}.${dependency}.enable";
})
requires;
}
]));
options.${prefix}.${name} =
lib.optionalAttrs (options != null && optionsSet ? ${namespace}) optionsSet.${namespace}
// {
enable = lib.mkEnableOption name;
};
}
|