From ce1dec774eb1650ca21adf7b621558fad9bb18cc Mon Sep 17 00:00:00 2001 From: Qubasa Date: Mon, 29 Jul 2024 17:33:42 +0200 Subject: [PATCH] clan-vm-manager: Fix regression --- .envrc | 1 + formatter.nix | 4 ++-- pkgs/clan-cli/clan_cli/clan/inspect.py | 4 ++-- pkgs/clan-cli/clan_cli/history/add.py | 2 +- pkgs/clan-cli/clan_cli/history/update.py | 4 ++-- pkgs/clan-cli/tests/test_history_cli.py | 2 +- .../clan_vm_manager/singletons/use_vms.py | 8 ++++---- pkgs/clan-vm-manager/default.nix | 12 ++---------- 8 files changed, 15 insertions(+), 22 deletions(-) diff --git a/.envrc b/.envrc index fda7fa8fb..37152103b 100644 --- a/.envrc +++ b/.envrc @@ -4,6 +4,7 @@ if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then fi watch_file .direnv/selected-shell +watch_file formatter.nix if [ -e .direnv/selected-shell ]; then use flake ".#$(cat .direnv/selected-shell)" diff --git a/formatter.nix b/formatter.nix index f5a64f8a6..8f6cbb285 100644 --- a/formatter.nix +++ b/formatter.nix @@ -30,8 +30,8 @@ { "pkgs/clan-vm-manager" = { extraPythonPackages = - # clan-app currently only exists on linux - self'.packages.clan-vm-manager.testDependencies ++ self'.packages.clan-cli.testDependencies; + # # clan-app currently only exists on linux + self'.packages.clan-vm-manager.testDependencies; modules = [ "clan_vm_manager" ]; }; } diff --git a/pkgs/clan-cli/clan_cli/clan/inspect.py b/pkgs/clan-cli/clan_cli/clan/inspect.py index c64009460..0c5b28636 100644 --- a/pkgs/clan-cli/clan_cli/clan/inspect.py +++ b/pkgs/clan-cli/clan_cli/clan/inspect.py @@ -14,7 +14,7 @@ from ..vms.inspect import VmConfig, inspect_vm @dataclass class FlakeConfig: - flake_url: str | Path + flake_url: FlakeId flake_attr: str clan_name: str @@ -89,7 +89,7 @@ def inspect_flake(flake_url: str | Path, machine_name: str) -> FlakeConfig: meta = nix_metadata(flake_url) return FlakeConfig( vm=vm, - flake_url=flake_url, + flake_url=FlakeId(flake_url), clan_name=clan_name, flake_attr=machine_name, nar_hash=meta["locked"]["narHash"], diff --git a/pkgs/clan-cli/clan_cli/history/add.py b/pkgs/clan-cli/clan_cli/history/add.py index b8c6dc011..e13938e86 100644 --- a/pkgs/clan-cli/clan_cli/history/add.py +++ b/pkgs/clan-cli/clan_cli/history/add.py @@ -62,7 +62,7 @@ def list_history() -> list[HistoryEntry]: def new_history_entry(url: str, machine: str) -> HistoryEntry: flake = inspect_flake(url, machine) - flake.flake_url = str(flake.flake_url) + flake.flake_url = flake.flake_url return HistoryEntry( flake=flake, last_used=datetime.datetime.now().isoformat(), diff --git a/pkgs/clan-cli/clan_cli/history/update.py b/pkgs/clan-cli/clan_cli/history/update.py index 6c263f80f..ed9c87abc 100644 --- a/pkgs/clan-cli/clan_cli/history/update.py +++ b/pkgs/clan-cli/clan_cli/history/update.py @@ -16,7 +16,7 @@ def update_history() -> list[HistoryEntry]: for entry in logs: try: - meta = nix_metadata(entry.flake.flake_url) + meta = nix_metadata(str(entry.flake.flake_url)) except ClanCmdError as e: print(f"Failed to update {entry.flake.flake_url}: {e}") continue @@ -31,7 +31,7 @@ def update_history() -> list[HistoryEntry]: machine_name=entry.flake.flake_attr, ) flake = inspect_flake(uri.get_url(), uri.machine_name) - flake.flake_url = str(flake.flake_url) + flake.flake_url = flake.flake_url entry = HistoryEntry( flake=flake, last_used=datetime.datetime.now().isoformat() ) diff --git a/pkgs/clan-cli/tests/test_history_cli.py b/pkgs/clan-cli/tests/test_history_cli.py index d08b1bb62..e65c7b2af 100644 --- a/pkgs/clan-cli/tests/test_history_cli.py +++ b/pkgs/clan-cli/tests/test_history_cli.py @@ -27,7 +27,7 @@ def test_history_add( history_file = user_history_file() assert history_file.exists() history = [HistoryEntry(**entry) for entry in json.loads(open(history_file).read())] - assert history[0].flake.flake_url == str(test_flake_with_core.path) + assert str(history[0].flake.flake_url["loc"]) == str(test_flake_with_core.path) @pytest.mark.impure diff --git a/pkgs/clan-vm-manager/clan_vm_manager/singletons/use_vms.py b/pkgs/clan-vm-manager/clan_vm_manager/singletons/use_vms.py index d88ae7c27..746361462 100644 --- a/pkgs/clan-vm-manager/clan_vm_manager/singletons/use_vms.py +++ b/pkgs/clan-vm-manager/clan_vm_manager/singletons/use_vms.py @@ -163,12 +163,12 @@ class ClanStore: del self.clan_store[str(vm.data.flake.flake_url)][vm.data.flake.flake_attr] def get_vm(self, uri: ClanURI) -> None | VMObject: - flake_id = Machine(uri.machine_name, uri.flake).get_id() - vm_store = self.clan_store.get(flake_id) + machine = Machine(uri.machine_name, uri.flake) + vm_store = self.clan_store.get(str(machine.flake)) if vm_store is None: return None - machine = vm_store.get(uri.machine_name, None) - return machine + vm = vm_store.get(str(machine.name), None) + return vm def get_running_vms(self) -> list[VMObject]: return [ diff --git a/pkgs/clan-vm-manager/default.nix b/pkgs/clan-vm-manager/default.nix index 4c15ee8ee..4ff1b90d0 100644 --- a/pkgs/clan-vm-manager/default.nix +++ b/pkgs/clan-vm-manager/default.nix @@ -39,7 +39,7 @@ let libadwaita webkitgtk_6_0 adwaita-icon-theme - ]; + ] ++ clan-cli.propagatedBuildInputs; # Deps including python packages from the local project allPythonDeps = [ (python3.pkgs.toPythonModule clan-cli) ] ++ externalPythonDeps; @@ -84,7 +84,6 @@ python3.pkgs.buildPythonApplication rec { setuptools copyDesktopItems wrapGAppsHook - gobject-introspection ]; @@ -93,14 +92,7 @@ python3.pkgs.buildPythonApplication rec { # that all necessary dependencies are consistently available both # at build time and runtime, buildInputs = allPythonDeps ++ runtimeDependencies; - propagatedBuildInputs = - allPythonDeps - ++ runtimeDependencies - ++ [ - - # TODO: see postFixup clan-cli/default.nix:L188 - clan-cli.propagatedBuildInputs - ]; + propagatedBuildInputs = allPythonDeps ++ runtimeDependencies ++ [ ]; # also re-expose dependencies so we test them in CI passthru = {