doctrine/lib: support module dependencies

This commit is contained in:
Alejandro Soto 2025-08-06 14:23:00 -06:00
parent e05a1ba575
commit 8a7c4f302c
No known key found for this signature in database
GPG key ID: A2C4C79764EE8F16

View file

@ -1,12 +1,14 @@
{
# The first few arguments are implicitly passed by the 'close' helper
lib,
pkgs,
doctrine,
name,
config,
hm ? null,
sys ? null,
options ? null,
lib,
config,
pkgs,
doctrine,
requires ? [],
}: let
optionsSet = import options {
inherit config lib pkgs cfg name doctrine;
@ -24,7 +26,17 @@
in {
config =
lib.optionalAttrs (configFiles ? ${doctrine.namespace})
(lib.mkIf cfg.enable configSet);
(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 = lib.optionalAttrs (options
!= null