refactor: rename clanCore -> clan.core
This commit is contained in:
@@ -15,7 +15,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
def create_backup(machine: Machine, provider: str | None = None) -> None:
|
||||
log.info(f"creating backup for {machine.name}")
|
||||
backup_scripts = json.loads(machine.eval_nix("config.clanCore.backups"))
|
||||
backup_scripts = json.loads(machine.eval_nix("config.clan.core.backups"))
|
||||
if provider is None:
|
||||
for provider in backup_scripts["providers"]:
|
||||
proc = machine.target_host.run(
|
||||
|
||||
@@ -20,7 +20,7 @@ class Backup:
|
||||
|
||||
def list_provider(machine: Machine, provider: str) -> list[Backup]:
|
||||
results = []
|
||||
backup_metadata = json.loads(machine.eval_nix("config.clanCore.backups"))
|
||||
backup_metadata = json.loads(machine.eval_nix("config.clan.core.backups"))
|
||||
proc = machine.target_host.run(
|
||||
[backup_metadata["providers"][provider]["list"]],
|
||||
stdout=subprocess.PIPE,
|
||||
@@ -40,7 +40,7 @@ def list_provider(machine: Machine, provider: str) -> list[Backup]:
|
||||
|
||||
|
||||
def list_backups(machine: Machine, provider: str | None = None) -> list[Backup]:
|
||||
backup_metadata = json.loads(machine.eval_nix("config.clanCore.backups"))
|
||||
backup_metadata = json.loads(machine.eval_nix("config.clan.core.backups"))
|
||||
results = []
|
||||
if provider is None:
|
||||
for _provider in backup_metadata["providers"]:
|
||||
|
||||
@@ -12,8 +12,8 @@ from ..machines.machines import Machine
|
||||
|
||||
|
||||
def restore_service(machine: Machine, name: str, provider: str, service: str) -> None:
|
||||
backup_metadata = json.loads(machine.eval_nix("config.clanCore.backups"))
|
||||
backup_folders = json.loads(machine.eval_nix("config.clanCore.state"))
|
||||
backup_metadata = json.loads(machine.eval_nix("config.clan.core.backups"))
|
||||
backup_folders = json.loads(machine.eval_nix("config.clan.core.state"))
|
||||
|
||||
if service not in backup_folders:
|
||||
msg = f"Service {service} not found in configuration. Available services are: {', '.join(backup_folders.keys())}"
|
||||
@@ -66,7 +66,7 @@ def restore_backup(
|
||||
) -> None:
|
||||
errors = []
|
||||
if service is None:
|
||||
backup_folders = json.loads(machine.eval_nix("config.clanCore.state"))
|
||||
backup_folders = json.loads(machine.eval_nix("config.clan.core.state"))
|
||||
for _service in backup_folders:
|
||||
try:
|
||||
restore_service(machine, name, provider, _service)
|
||||
|
||||
@@ -56,7 +56,7 @@ def inspect_flake(flake_url: str | Path, machine_name: str) -> FlakeConfig:
|
||||
# Get the Clan name
|
||||
cmd = nix_eval(
|
||||
[
|
||||
f'{flake_url}#clanInternals.machines."{system}"."{machine_name}".config.clanCore.clanName'
|
||||
f'{flake_url}#clanInternals.machines."{system}"."{machine_name}".config.clan.core.clanName'
|
||||
]
|
||||
)
|
||||
res = run_cmd(cmd)
|
||||
@@ -65,7 +65,7 @@ def inspect_flake(flake_url: str | Path, machine_name: str) -> FlakeConfig:
|
||||
# Get the clan icon path
|
||||
cmd = nix_eval(
|
||||
[
|
||||
f'{flake_url}#clanInternals.machines."{system}"."{machine_name}".config.clanCore.clanIcon'
|
||||
f'{flake_url}#clanInternals.machines."{system}"."{machine_name}".config.clan.core.clanIcon'
|
||||
]
|
||||
)
|
||||
res = run_cmd(cmd)
|
||||
@@ -78,7 +78,7 @@ def inspect_flake(flake_url: str | Path, machine_name: str) -> FlakeConfig:
|
||||
|
||||
cmd = nix_build(
|
||||
[
|
||||
f'{flake_url}#clanInternals.machines."{system}"."{machine_name}".config.clanCore.clanIcon'
|
||||
f'{flake_url}#clanInternals.machines."{system}"."{machine_name}".config.clan.core.clanIcon'
|
||||
],
|
||||
machine_gcroot(flake_url=str(flake_url)) / "clanIcon",
|
||||
)
|
||||
|
||||
@@ -95,7 +95,7 @@ def complete_services_for_machine(
|
||||
run(
|
||||
nix_eval(
|
||||
flags=[
|
||||
f"{flake}#nixosConfigurations.{machines[0]}.config.clanCore.facts.services",
|
||||
f"{flake}#nixosConfigurations.{machines[0]}.config.clan.core.facts.services",
|
||||
"--apply",
|
||||
"builtins.attrNames",
|
||||
],
|
||||
@@ -137,7 +137,7 @@ def complete_backup_providers_for_machine(
|
||||
run(
|
||||
nix_eval(
|
||||
flags=[
|
||||
f"{flake}#nixosConfigurations.{machine}.config.clanCore.backups.providers",
|
||||
f"{flake}#nixosConfigurations.{machine}.config.clan.core.backups.providers",
|
||||
"--apply",
|
||||
"builtins.attrNames",
|
||||
],
|
||||
|
||||
@@ -114,7 +114,7 @@ def options_for_machine(
|
||||
if show_trace:
|
||||
flags.append("--show-trace")
|
||||
flags.append(
|
||||
f"{clan_dir}#nixosConfigurations.{machine_name}.config.clanCore.optionsNix"
|
||||
f"{clan_dir}#nixosConfigurations.{machine_name}.config.clan.core.optionsNix"
|
||||
)
|
||||
cmd = nix_eval(flags=flags)
|
||||
proc = run(
|
||||
|
||||
@@ -50,7 +50,7 @@ def verify_machine_config(
|
||||
# potentially the config might affect submodule options,
|
||||
# therefore we need to import it
|
||||
config
|
||||
{{clanCore.clanDir = {flake};}}
|
||||
{{clan.core.clanDir = {flake};}}
|
||||
]
|
||||
# add all clan modules specified via clanImports
|
||||
++ (map (name: clan-core.clanModules.${{name}}) config.clanImports or []);
|
||||
|
||||
@@ -84,7 +84,7 @@ def machine_schema(
|
||||
# potentially the config might affect submodule options,
|
||||
# therefore we need to import it
|
||||
config
|
||||
{{ clanCore.clanName = "fakeClan"; }}
|
||||
{{ clan.core.clanName = "fakeClan"; }}
|
||||
]
|
||||
# add all clan modules specified via clanImports
|
||||
++ (map (name: clan-core.clanModules.${{name}}) config.clanImports or []);
|
||||
|
||||
@@ -29,7 +29,7 @@ def show_machine(flake_url: str | Path, machine_name: str) -> MachineInfo:
|
||||
[
|
||||
f"{flake_url}#clanInternals.machines.{system}.{machine_name}",
|
||||
"--apply",
|
||||
"machine: { inherit (machine.config.clanCore) machineDescription machineIcon machineName; }",
|
||||
"machine: { inherit (machine.config.clan.core) machineDescription machineIcon machineName; }",
|
||||
"--json",
|
||||
]
|
||||
)
|
||||
|
||||
@@ -22,7 +22,7 @@ class VmConfig:
|
||||
|
||||
|
||||
def inspect_vm(machine: Machine) -> VmConfig:
|
||||
data = json.loads(machine.eval_nix("config.clanCore.vm.inspect"))
|
||||
data = json.loads(machine.eval_nix("config.clan.core.vm.inspect"))
|
||||
return VmConfig(flake_url=str(machine.flake), **data)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user