diff --git a/pkgs/clan-cli/clan_cli/clan/show.py b/pkgs/clan-cli/clan_cli/clan/show.py index 93f24d2e5..f182d396b 100644 --- a/pkgs/clan-cli/clan_cli/clan/show.py +++ b/pkgs/clan-cli/clan_cli/clan/show.py @@ -9,7 +9,7 @@ from clan_lib.cmd import run from clan_lib.errors import ClanCmdError, ClanError from clan_lib.flake import Flake from clan_lib.nix import nix_eval -from clan_lib.nix_models.inventory import Meta +from clan_lib.nix_models.clan import InventoryMeta as Meta log = logging.getLogger(__name__) diff --git a/pkgs/clan-cli/clan_cli/clan/update.py b/pkgs/clan-cli/clan_cli/clan/update.py index e47b002cb..7e1ac3355 100644 --- a/pkgs/clan-cli/clan_cli/clan/update.py +++ b/pkgs/clan-cli/clan_cli/clan/update.py @@ -2,7 +2,8 @@ from dataclasses import dataclass from clan_lib.api import API from clan_lib.flake import Flake -from clan_lib.nix_models.inventory import Inventory, Meta +from clan_lib.nix_models.clan import Inventory +from clan_lib.nix_models.clan import InventoryMeta as Meta from clan_lib.persist.inventory_store import InventoryStore from clan_lib.persist.util import set_value_by_path diff --git a/pkgs/clan-cli/clan_cli/machines/create.py b/pkgs/clan-cli/clan_cli/machines/create.py index 76a358070..9aa8359f8 100644 --- a/pkgs/clan-cli/clan_cli/machines/create.py +++ b/pkgs/clan-cli/clan_cli/machines/create.py @@ -9,12 +9,8 @@ from clan_lib.dirs import get_clan_flake_toplevel_or_env from clan_lib.errors import ClanError from clan_lib.flake import Flake from clan_lib.git import commit_file -from clan_lib.nix_models.inventory import ( - Machine as InventoryMachine, -) -from clan_lib.nix_models.inventory import ( - MachineDeploy, -) +from clan_lib.nix_models.clan import InventoryMachine +from clan_lib.nix_models.clan import InventoryMachineDeploy as MachineDeploy from clan_lib.persist.inventory_store import InventoryStore from clan_lib.persist.util import set_value_by_path from clan_lib.templates import ( diff --git a/pkgs/clan-cli/clan_cli/machines/list.py b/pkgs/clan-cli/clan_cli/machines/list.py index cff1eb1e3..121bcdd56 100644 --- a/pkgs/clan-cli/clan_cli/machines/list.py +++ b/pkgs/clan-cli/clan_cli/machines/list.py @@ -11,7 +11,7 @@ from clan_lib.errors import ClanError from clan_lib.flake import Flake from clan_lib.machines.actions import get_machine from clan_lib.machines.machines import Machine -from clan_lib.nix_models.inventory import Machine as InventoryMachine +from clan_lib.nix_models.clan import InventoryMachine from clan_lib.persist.inventory_store import InventoryStore from clan_cli.completions import add_dynamic_completer, complete_tags diff --git a/pkgs/clan-cli/clan_cli/machines/morph.py b/pkgs/clan-cli/clan_cli/machines/morph.py index f9adb5739..6dbf7f669 100644 --- a/pkgs/clan-cli/clan_cli/machines/morph.py +++ b/pkgs/clan-cli/clan_cli/machines/morph.py @@ -13,7 +13,7 @@ from clan_lib.errors import ClanError from clan_lib.flake import Flake from clan_lib.machines.machines import Machine from clan_lib.nix import nix_build, nix_command -from clan_lib.nix_models.inventory import Machine as InventoryMachine +from clan_lib.nix_models.clan import InventoryMachine from clan_cli.machines.create import CreateOptions, create_machine from clan_cli.vars.generate import generate_vars diff --git a/pkgs/clan-cli/clan_cli/tests/test_inventory.py b/pkgs/clan-cli/clan_cli/tests/test_inventory.py index 773fd284f..d91939e6f 100644 --- a/pkgs/clan-cli/clan_cli/tests/test_inventory.py +++ b/pkgs/clan-cli/clan_cli/tests/test_inventory.py @@ -1,4 +1,7 @@ -from clan_lib.nix_models.inventory import Inventory, Machine, Meta, Service +from clan_lib.nix_models.clan import Inventory +from clan_lib.nix_models.clan import InventoryMachine as Machine +from clan_lib.nix_models.clan import InventoryMeta as Meta +from clan_lib.nix_models.clan import InventoryService as Service def test_make_meta_minimal() -> None: diff --git a/pkgs/clan-cli/clan_cli/tests/test_modules.py b/pkgs/clan-cli/clan_cli/tests/test_modules.py index ca6d2df1b..78e9ab835 100644 --- a/pkgs/clan-cli/clan_cli/tests/test_modules.py +++ b/pkgs/clan-cli/clan_cli/tests/test_modules.py @@ -8,9 +8,11 @@ from clan_cli.tests.fixtures_flakes import FlakeForTest from clan_lib.api.modules import list_modules from clan_lib.flake import Flake from clan_lib.nix import nix_eval, run -from clan_lib.nix_models.inventory import ( - Machine, - MachineDeploy, +from clan_lib.nix_models.clan import ( + InventoryMachine as Machine, +) +from clan_lib.nix_models.clan import ( + InventoryMachineDeploy as MachineDeploy, ) from clan_lib.persist.inventory_store import InventoryStore from clan_lib.persist.util import set_value_by_path diff --git a/pkgs/clan-cli/clan_lib/clan/create.py b/pkgs/clan-cli/clan_lib/clan/create.py index 9922e36e9..4fb7a1a61 100644 --- a/pkgs/clan-cli/clan_lib/clan/create.py +++ b/pkgs/clan-cli/clan_lib/clan/create.py @@ -7,7 +7,7 @@ from clan_lib.cmd import CmdOut, RunOpts, run from clan_lib.errors import ClanError from clan_lib.flake import Flake from clan_lib.nix import nix_command, nix_metadata, nix_shell -from clan_lib.nix_models.inventory import Inventory +from clan_lib.nix_models.clan import Inventory from clan_lib.persist.inventory_store import InventoryStore from clan_lib.templates import ( InputPrio, diff --git a/pkgs/clan-cli/clan_lib/inventory/__init__.py b/pkgs/clan-cli/clan_lib/inventory/__init__.py index 70a64cfe8..8e5114de2 100644 --- a/pkgs/clan-cli/clan_lib/inventory/__init__.py +++ b/pkgs/clan-cli/clan_lib/inventory/__init__.py @@ -13,7 +13,7 @@ Interacting with 'clan_lib.inventory' is NOT recommended and will be removed from clan_lib.api import API from clan_lib.flake import Flake -from clan_lib.nix_models.inventory import Inventory +from clan_lib.nix_models.clan import Inventory from clan_lib.persist.inventory_store import InventoryStore diff --git a/pkgs/clan-cli/clan_lib/machines/actions.py b/pkgs/clan-cli/clan_lib/machines/actions.py index e34a34a08..067b05142 100644 --- a/pkgs/clan-cli/clan_lib/machines/actions.py +++ b/pkgs/clan-cli/clan_lib/machines/actions.py @@ -1,8 +1,8 @@ from clan_lib.api import API from clan_lib.errors import ClanError from clan_lib.machines.machines import Machine -from clan_lib.nix_models.inventory import ( - Machine as InventoryMachine, +from clan_lib.nix_models.clan import ( + InventoryMachine, ) from clan_lib.persist.inventory_store import InventoryStore from clan_lib.persist.util import set_value_by_path diff --git a/pkgs/clan-cli/clan_lib/nix_models/clan.py b/pkgs/clan-cli/clan_lib/nix_models/clan.py new file mode 100644 index 000000000..066ef7a9e --- /dev/null +++ b/pkgs/clan-cli/clan_lib/nix_models/clan.py @@ -0,0 +1,200 @@ +# DO NOT EDIT THIS FILE MANUALLY. IT IS GENERATED. +# This file was generated by running `pkgs/clan-cli/clan_lib.inventory/update.sh` +# +# ruff: noqa: N815 +# ruff: noqa: N806 +# ruff: noqa: F401 +# fmt: off +from typing import Any, Literal, NotRequired, TypedDict + + +# Mimic "unknown". +# 'Any' is unsafe because it allows any operations +# This forces the user to use type-narrowing or casting in the code +class Unknown: + pass + + +InventoryInstanceModuleNameType = str +InventoryInstanceModuleInputType = str + +class InventoryInstanceModule(TypedDict): + name: str + input: NotRequired[InventoryInstanceModuleInputType] + + + +InventoryInstanceRoleMachineSettingsType = Unknown + +class InventoryInstanceRoleMachine(TypedDict): + settings: NotRequired[InventoryInstanceRoleMachineSettingsType] + + + + + +class InventoryInstanceRoleTag(TypedDict): + pass + + + +InventoryInstanceRoleMachinesType = dict[str, InventoryInstanceRoleMachine] +InventoryInstanceRoleSettingsType = Unknown +InventoryInstanceRoleTagsType = dict[str, InventoryInstanceRoleTag] + +class InventoryInstanceRole(TypedDict): + machines: NotRequired[InventoryInstanceRoleMachinesType] + settings: NotRequired[InventoryInstanceRoleSettingsType] + tags: NotRequired[InventoryInstanceRoleTagsType] + + + +InventoryInstanceModuleType = InventoryInstanceModule +InventoryInstanceRolesType = dict[str, InventoryInstanceRole] + +class InventoryInstance(TypedDict): + module: NotRequired[InventoryInstanceModuleType] + roles: NotRequired[InventoryInstanceRolesType] + + + +InventoryMachineDeployTargethostType = str | None + +class InventoryMachineDeploy(TypedDict): + targetHost: NotRequired[InventoryMachineDeployTargethostType] + + + +InventoryMachineDeployType = InventoryMachineDeploy +InventoryMachineDescriptionType = str | None +InventoryMachineIconType = str | None +InventoryMachineMachineclassType = Literal["nixos", "darwin"] +InventoryMachineNameType = str +InventoryMachineTagsType = list[str] + +class InventoryMachine(TypedDict): + deploy: NotRequired[InventoryMachineDeployType] + description: NotRequired[InventoryMachineDescriptionType] + icon: NotRequired[InventoryMachineIconType] + machineClass: NotRequired[InventoryMachineMachineclassType] + name: NotRequired[InventoryMachineNameType] + tags: NotRequired[InventoryMachineTagsType] + + + +InventoryMetaNameType = str +InventoryMetaDescriptionType = str | None +InventoryMetaIconType = str | None + +class InventoryMeta(TypedDict): + name: str + description: NotRequired[InventoryMetaDescriptionType] + icon: NotRequired[InventoryMetaIconType] + + + + + +class InventoryService(TypedDict): + pass + + + +InventoryInstancesType = dict[str, InventoryInstance] +InventoryMachinesType = dict[str, InventoryMachine] +InventoryMetaType = InventoryMeta +InventoryModulesType = dict[str, dict[str, Any] | list[Any] | bool | float | int | str | None] +InventoryServicesType = dict[str, InventoryService] +InventoryTagsType = dict[str, list[str]] + +class Inventory(TypedDict): + instances: NotRequired[InventoryInstancesType] + machines: NotRequired[InventoryMachinesType] + meta: NotRequired[InventoryMetaType] + modules: NotRequired[InventoryModulesType] + services: NotRequired[InventoryServicesType] + tags: NotRequired[InventoryTagsType] + + + +OutputModuleformachineType = dict[str, Unknown] + +class Output(TypedDict): + moduleForMachine: NotRequired[OutputModuleformachineType] + + + +SecretAgePluginsType = list[str] + +class SecretAge(TypedDict): + plugins: NotRequired[SecretAgePluginsType] + + + +SecretAgeType = SecretAge + +class Secret(TypedDict): + age: NotRequired[SecretAgeType] + + + +TemplateClanPathType = str +TemplateClanDescriptionType = str + +class TemplateClan(TypedDict): + path: str + description: NotRequired[TemplateClanDescriptionType] + + + +TemplateDiskoPathType = str +TemplateDiskoDescriptionType = str + +class TemplateDisko(TypedDict): + path: str + description: NotRequired[TemplateDiskoDescriptionType] + + + +TemplateMachinePathType = str +TemplateMachineDescriptionType = str + +class TemplateMachine(TypedDict): + path: str + description: NotRequired[TemplateMachineDescriptionType] + + + +TemplateClanType = dict[str, TemplateClan] +TemplateDiskoType = dict[str, TemplateDisko] +TemplateMachineType = dict[str, TemplateMachine] + +class Template(TypedDict): + clan: NotRequired[TemplateClanType] + disko: NotRequired[TemplateDiskoType] + machine: NotRequired[TemplateMachineType] + + + +ClanDirectoryType = dict[str, Any] | list[Any] | bool | float | int | str +ClanInventoryType = Inventory +ClanMachinesType = dict[str, Unknown] +ClanMetaType = Unknown +ClanModulesType = dict[str, Unknown] +ClanOutputsType = Output +ClanSecretsType = Secret +ClanSelfType = dict[str, Any] | list[Any] | bool | float | int | str +ClanSpecialargsType = dict[str, dict[str, Any] | list[Any] | bool | float | int | str | None] +ClanTemplatesType = Template + +class Clan(TypedDict): + directory: NotRequired[ClanDirectoryType] + inventory: NotRequired[ClanInventoryType] + machines: NotRequired[ClanMachinesType] + meta: NotRequired[ClanMetaType] + modules: NotRequired[ClanModulesType] + outputs: NotRequired[ClanOutputsType] + secrets: NotRequired[ClanSecretsType] + self: NotRequired[ClanSelfType] + specialArgs: NotRequired[ClanSpecialargsType] + templates: NotRequired[ClanTemplatesType] diff --git a/pkgs/clan-cli/clan_lib/nix_models/inventory.py b/pkgs/clan-cli/clan_lib/nix_models/inventory.py deleted file mode 100644 index 1d57a281b..000000000 --- a/pkgs/clan-cli/clan_lib/nix_models/inventory.py +++ /dev/null @@ -1,111 +0,0 @@ -# DO NOT EDIT THIS FILE MANUALLY. IT IS GENERATED. -# This file was generated by running `pkgs/clan-cli/clan_lib.inventory/update.sh` -# -# ruff: noqa: N815 -# ruff: noqa: N806 -# ruff: noqa: F401 -# fmt: off -from typing import Any, Literal, NotRequired, TypedDict - - -# Mimic "unknown". -# 'Any' is unsafe because it allows any operations -# This forces the user to use type-narrowing or casting in the code -class Unknown: - pass - - -InstanceModuleNameType = str -InstanceModuleInputType = str - -class InstanceModule(TypedDict): - name: str - input: NotRequired[InstanceModuleInputType] - - - -InstanceRoleMachineSettingsType = Unknown - -class InstanceRoleMachine(TypedDict): - settings: NotRequired[InstanceRoleMachineSettingsType] - - - - - -class InstanceRoleTag(TypedDict): - pass - - - -InstanceRoleMachinesType = dict[str, InstanceRoleMachine] -InstanceRoleSettingsType = Unknown -InstanceRoleTagsType = dict[str, InstanceRoleTag] - -class InstanceRole(TypedDict): - machines: NotRequired[InstanceRoleMachinesType] - settings: NotRequired[InstanceRoleSettingsType] - tags: NotRequired[InstanceRoleTagsType] - - - -InstanceModuleType = InstanceModule -InstanceRolesType = dict[str, InstanceRole] - -class Instance(TypedDict): - module: NotRequired[InstanceModuleType] - roles: NotRequired[InstanceRolesType] - - - -MachineDeployTargethostType = str - -class MachineDeploy(TypedDict): - targetHost: NotRequired[MachineDeployTargethostType] - - - -MachineDeployType = MachineDeploy -MachineDescriptionType = str -MachineIconType = str -MachineMachineclassType = Literal["nixos", "darwin"] -MachineNameType = str -MachineTagsType = list[str] - -class Machine(TypedDict): - deploy: NotRequired[MachineDeployType] - description: NotRequired[MachineDescriptionType] - icon: NotRequired[MachineIconType] - machineClass: NotRequired[MachineMachineclassType] - name: NotRequired[MachineNameType] - tags: NotRequired[MachineTagsType] - - - -MetaNameType = str -MetaDescriptionType = str -MetaIconType = str - -class Meta(TypedDict): - name: str - description: NotRequired[MetaDescriptionType] - icon: NotRequired[MetaIconType] - -Service = dict[str, Any] - - - -InventoryInstancesType = dict[str, Instance] -InventoryMachinesType = dict[str, Machine] -InventoryMetaType = Meta -InventoryModulesType = dict[str, Any] -InventoryServicesType = dict[str, Service] -InventoryTagsType = dict[str, Any] - -class Inventory(TypedDict): - instances: NotRequired[InventoryInstancesType] - machines: NotRequired[InventoryMachinesType] - meta: NotRequired[InventoryMetaType] - modules: NotRequired[InventoryModulesType] - services: NotRequired[InventoryServicesType] - tags: NotRequired[InventoryTagsType] diff --git a/pkgs/clan-cli/clan_lib/persist/inventory_store.py b/pkgs/clan-cli/clan_lib/persist/inventory_store.py index 898638c8a..92944dfde 100644 --- a/pkgs/clan-cli/clan_lib/persist/inventory_store.py +++ b/pkgs/clan-cli/clan_lib/persist/inventory_store.py @@ -5,7 +5,7 @@ from typing import Any, Protocol from clan_lib.errors import ClanError from clan_lib.git import commit_file -from clan_lib.nix_models.inventory import Inventory +from clan_lib.nix_models.clan import Inventory from .util import ( calc_patches, diff --git a/pkgs/clan-cli/clan_lib/tests/test_create.py b/pkgs/clan-cli/clan_lib/tests/test_create.py index ff889506e..eff98593a 100644 --- a/pkgs/clan-cli/clan_lib/tests/test_create.py +++ b/pkgs/clan-cli/clan_lib/tests/test_create.py @@ -24,8 +24,8 @@ from clan_lib.errors import ClanError from clan_lib.flake import Flake from clan_lib.machines.machines import Machine from clan_lib.nix import nix_command -from clan_lib.nix_models.inventory import Machine as InventoryMachine -from clan_lib.nix_models.inventory import MachineDeploy +from clan_lib.nix_models.clan import InventoryMachine +from clan_lib.nix_models.clan import InventoryMachineDeploy as MachineDeploy from clan_lib.ssh.remote import Remote log = logging.getLogger(__name__)