chore(inventory/instances): don't eagerly test the service modules _class

This commit is contained in:
Johannes Kirschbauer
2025-04-08 15:09:22 +02:00
parent f7d5a529aa
commit 9af20ad8b5
4 changed files with 24 additions and 32 deletions

View File

@@ -66,21 +66,32 @@ let
allModules.${serviceName}
or (throw "(Legacy) ClanModule not found: '${serviceName}'. Make sure the module is added to ${scope}");
moduleType = (lib.typeOf module);
checked = if builtins.elem moduleType ["string" "path"] then true else throw "(Legacy) ClanModule must be a 'path' or 'string' pointing to a directory: Got 'typeOf inventory.modules.${serviceName}' => ${moduleType} ";
checked =
if
builtins.elem moduleType [
"string"
"path"
]
then
true
else
throw "(Legacy) ClanModule must be a 'path' or 'string' pointing to a directory: Got 'typeOf inventory.modules.${serviceName}' => ${moduleType} ";
modulePath = lib.seq checked module + "/roles";
checkedPath = if builtins.pathExists modulePath then modulePath else throw ''
(Legacy) ClanModule must have a 'roles' directory'
checkedPath =
if builtins.pathExists modulePath then
modulePath
else
throw ''
(Legacy) ClanModule must have a 'roles' directory'
Fixes:
- Provide a 'roles' subdirectory
- Use the newer 'clan.service' modules. (Recommended)
'';
Fixes:
- Provide a 'roles' subdirectory
- Use the newer 'clan.service' modules. (Recommended)
'';
in
lib.seq checkedPath lib.mapAttrsToList (name: _value: trimExtension name) (
lib.filterAttrs (name: type: type == "regular" && lib.hasSuffix ".nix" name) (
builtins.readDir (
checkedPath
)
builtins.readDir (checkedPath)
)
);