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