diff --git a/lib/inventory/distributed-service/service-module.nix b/lib/inventory/distributed-service/service-module.nix index 5c07ea894..865595ae0 100644 --- a/lib/inventory/distributed-service/service-module.nix +++ b/lib/inventory/distributed-service/service-module.nix @@ -859,7 +859,11 @@ in instanceRes.nixosModule ] ++ (map ( - s: if builtins.typeOf s == "string" then "${directory}/${s}" else s + s: + if builtins.typeOf s == "string" then + lib.warn "String types for 'extraModules' will be deprecated - ${s}" "${directory}/${s}" + else + lib.setDefaultModuleLocation "via inventory.instances.${instanceName}.roles.${roleName}" s ) instanceCfg.roles.${roleName}.extraModules); }; } diff --git a/modules/inventoryClass/role.nix b/modules/inventoryClass/role.nix index 650cc56d1..f80204c4d 100644 --- a/modules/inventoryClass/role.nix +++ b/modules/inventoryClass/role.nix @@ -44,12 +44,6 @@ in description = '' List of additionally imported `.nix` expressions. - Supported types: - - - **Strings**: Interpreted relative to the 'directory' passed to `lib.clan`. - - **Paths**: should be relative to the current file. - - **Any**: Nix expression must be serializable to JSON. - !!! Note **The import only happens if the machine is part of the service or role.** @@ -74,7 +68,7 @@ in ``` ''; default = [ ]; - type = types.listOf types.deferredModule; + type = types.listOf types.raw; }; }; } diff --git a/pkgs/clan-cli/clan_lib/api/__init__.py b/pkgs/clan-cli/clan_lib/api/__init__.py index d3a0f8504..148806854 100644 --- a/pkgs/clan-cli/clan_lib/api/__init__.py +++ b/pkgs/clan-cli/clan_lib/api/__init__.py @@ -243,7 +243,11 @@ API.register(get_system_file) if "oneOf" not in return_type: msg = ( f"Return type of function '{name}' is not a union type. Expected a union of Success and Error types." - # @DavHau: no idea wy exactly this leads to the "oneOf" ot being present, but this should help + # If the SuccessData type is unsupported it was dropped by Union narrowing. + # This is probably an antifeature + # Introduced because run_generator wanted to use: + # Callable[[Generator], dict[str, str]] + # In its function signature. "Hint: When using dataclasses as return types, ensure they don't contain public fields with non-serializable types" ) raise JSchemaTypeError(msg) diff --git a/pkgs/clan-cli/clan_lib/nix_models/clan.py b/pkgs/clan-cli/clan_lib/nix_models/clan.py index 5cf42e02a..e2bd4563c 100644 --- a/pkgs/clan-cli/clan_lib/nix_models/clan.py +++ b/pkgs/clan-cli/clan_lib/nix_models/clan.py @@ -28,13 +28,11 @@ class InventoryInstanceRoleMachine(TypedDict): -InventoryInstanceRoleExtramodulesType = list[Unknown] InventoryInstanceRoleMachinesType = dict[str, InventoryInstanceRoleMachine] InventoryInstanceRoleSettingsType = Unknown InventoryInstanceRoleTagsType = dict[str, Any] | list[str] class InventoryInstanceRole(TypedDict): - extraModules: NotRequired[InventoryInstanceRoleExtramodulesType] machines: NotRequired[InventoryInstanceRoleMachinesType] settings: NotRequired[InventoryInstanceRoleSettingsType] tags: NotRequired[InventoryInstanceRoleTagsType] diff --git a/pkgs/classgen/main.py b/pkgs/classgen/main.py index e064d23b1..937b91d8a 100644 --- a/pkgs/classgen/main.py +++ b/pkgs/classgen/main.py @@ -241,6 +241,11 @@ def generate_dataclass( # If we are at the top level, and the attribute name is not explicitly included we only do shallow field_name = prop.replace("-", "_") + # Skip "extraModules" + # TODO: Introduce seperate model that is tied to the serialization format + if "extraModules" in field_name: + continue + # if len(attr_path) == 0 and prop in shallow_attrs: # field_def = field_name, "dict[str, Any]" # fields_with_default.append(field_def)