Inventory: only declare the module namespace if any config is defined
This commit is contained in:
@@ -141,9 +141,9 @@ let
|
|||||||
throw "Module doesn't have role: '${role}'. Path: ${path} not found."
|
throw "Module doesn't have role: '${role}'. Path: ${path} not found."
|
||||||
) inverseRoles.${machineName} or [ ];
|
) inverseRoles.${machineName} or [ ];
|
||||||
|
|
||||||
roleServiceConfigs = builtins.map (
|
roleServiceConfigs = builtins.filter (m: m != { }) (
|
||||||
role: serviceConfig.roles.${role}.config or { }
|
builtins.map (role: serviceConfig.roles.${role}.config or { }) inverseRoles.${machineName} or [ ]
|
||||||
) inverseRoles.${machineName} or [ ];
|
);
|
||||||
|
|
||||||
customImports = map (s: "${directory}/${s}") (
|
customImports = map (s: "${directory}/${s}") (
|
||||||
globalImports ++ machineImports ++ roleServiceImports
|
globalImports ++ machineImports ++ roleServiceImports
|
||||||
@@ -155,14 +155,19 @@ let
|
|||||||
++ [
|
++ [
|
||||||
{
|
{
|
||||||
imports = [ clan-core.clanModules.${serviceName} ] ++ roleModules ++ customImports;
|
imports = [ clan-core.clanModules.${serviceName} ] ++ roleModules ++ customImports;
|
||||||
|
}
|
||||||
|
(lib.optionalAttrs (globalConfig != { } || machineServiceConfig != { } || roleServiceConfigs != [ ])
|
||||||
|
{
|
||||||
config.clan.${serviceName} = lib.mkMerge (
|
config.clan.${serviceName} = lib.mkMerge (
|
||||||
[
|
[
|
||||||
globalConfig
|
(globalConfig)
|
||||||
machineServiceConfig
|
(lib.traceValSeq machineServiceConfig)
|
||||||
]
|
]
|
||||||
++ roleServiceConfigs
|
++ (roleServiceConfigs)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
|
||||||
{
|
{
|
||||||
config.clan.inventory.services.${serviceName}.${instanceName} = {
|
config.clan.inventory.services.${serviceName}.${instanceName} = {
|
||||||
roles = resolvedRoles;
|
roles = resolvedRoles;
|
||||||
|
|||||||
Reference in New Issue
Block a user