"""Data models for host configuration.""" from dataclasses import dataclass from typing import Optional @dataclass class HostConfig: """Configuration for a new NixOS host.""" hostname: str ip: Optional[str] = None cpu: int = 2 memory: int = 2048 disk: str = "20G" @property def is_static_ip(self) -> bool: """Check if host uses static IP configuration.""" return self.ip is not None @property def gateway(self) -> str: """Default gateway for the network.""" return "10.69.13.1" @property def nameservers(self) -> list[str]: """DNS nameservers for the network.""" return ["10.69.13.5", "10.69.13.6"] @property def domain(self) -> str: """Domain name for the network.""" return "home.2rjus.net" @property def state_version(self) -> str: """NixOS state version for new hosts.""" return "25.11" def validate(self) -> None: """Validate configuration constraints.""" if not self.hostname: raise ValueError("Hostname cannot be empty") if self.cpu < 1: raise ValueError("CPU cores must be at least 1") if self.memory < 512: raise ValueError("Memory must be at least 512 MB") if not self.disk: raise ValueError("Disk size cannot be empty")