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

@@ -120,22 +120,13 @@ let
# TODO: Eagerly check the _class of the resolved module
importedModulesEvaluated = lib.mapAttrs (
_module_ident: instances:
let
matchedClass = "clan.service";
instance = (builtins.head instances).instance;
classCheckedModule =
if instance.moduleClass == matchedClass then
instance.resolvedModule
else
(throw ''Module '${instance.module.name}' is not a valid '${matchedClass}' module. Got module with class:${builtins.toJSON instance.moduleClass}'');
in
(lib.evalModules {
class = matchedClass;
class = "clan.service";
modules =
[
./service-module.nix
# Import the resolved module
classCheckedModule
# Import the resolved module.
(builtins.head instances).instance.resolvedModule
]
# Include all the instances that correlate to the resolved module
++ (builtins.map (v: {

View File

@@ -53,13 +53,4 @@ in
};
};
};
# Currently this should fail
# TODO: Can we implement a default wrapper to make migration easy?
test_import_local_legacy_module = {
expr = (resolve { name = "B"; }).allMachines;
expectedError = {
type = "ThrownError";
msg = "Module 'B' is not a valid 'clan.service' module.*";
};
};
}