Merge pull request 'clan-vm-manager: Fix regression' (#1818) from Qubasa/clan-core:Qubasa-main into main
This commit is contained in:
1
.envrc
1
.envrc
@@ -4,6 +4,7 @@ if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
watch_file .direnv/selected-shell
|
watch_file .direnv/selected-shell
|
||||||
|
watch_file formatter.nix
|
||||||
|
|
||||||
if [ -e .direnv/selected-shell ]; then
|
if [ -e .direnv/selected-shell ]; then
|
||||||
use flake ".#$(cat .direnv/selected-shell)"
|
use flake ".#$(cat .direnv/selected-shell)"
|
||||||
|
|||||||
@@ -30,8 +30,8 @@
|
|||||||
{
|
{
|
||||||
"pkgs/clan-vm-manager" = {
|
"pkgs/clan-vm-manager" = {
|
||||||
extraPythonPackages =
|
extraPythonPackages =
|
||||||
# clan-app currently only exists on linux
|
# # clan-app currently only exists on linux
|
||||||
self'.packages.clan-vm-manager.testDependencies ++ self'.packages.clan-cli.testDependencies;
|
self'.packages.clan-vm-manager.testDependencies;
|
||||||
modules = [ "clan_vm_manager" ];
|
modules = [ "clan_vm_manager" ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ from ..vms.inspect import VmConfig, inspect_vm
|
|||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class FlakeConfig:
|
class FlakeConfig:
|
||||||
flake_url: str | Path
|
flake_url: FlakeId
|
||||||
flake_attr: str
|
flake_attr: str
|
||||||
|
|
||||||
clan_name: str
|
clan_name: str
|
||||||
@@ -89,7 +89,7 @@ def inspect_flake(flake_url: str | Path, machine_name: str) -> FlakeConfig:
|
|||||||
meta = nix_metadata(flake_url)
|
meta = nix_metadata(flake_url)
|
||||||
return FlakeConfig(
|
return FlakeConfig(
|
||||||
vm=vm,
|
vm=vm,
|
||||||
flake_url=flake_url,
|
flake_url=FlakeId(flake_url),
|
||||||
clan_name=clan_name,
|
clan_name=clan_name,
|
||||||
flake_attr=machine_name,
|
flake_attr=machine_name,
|
||||||
nar_hash=meta["locked"]["narHash"],
|
nar_hash=meta["locked"]["narHash"],
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ def list_history() -> list[HistoryEntry]:
|
|||||||
|
|
||||||
def new_history_entry(url: str, machine: str) -> HistoryEntry:
|
def new_history_entry(url: str, machine: str) -> HistoryEntry:
|
||||||
flake = inspect_flake(url, machine)
|
flake = inspect_flake(url, machine)
|
||||||
flake.flake_url = str(flake.flake_url)
|
flake.flake_url = flake.flake_url
|
||||||
return HistoryEntry(
|
return HistoryEntry(
|
||||||
flake=flake,
|
flake=flake,
|
||||||
last_used=datetime.datetime.now().isoformat(),
|
last_used=datetime.datetime.now().isoformat(),
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ def update_history() -> list[HistoryEntry]:
|
|||||||
|
|
||||||
for entry in logs:
|
for entry in logs:
|
||||||
try:
|
try:
|
||||||
meta = nix_metadata(entry.flake.flake_url)
|
meta = nix_metadata(str(entry.flake.flake_url))
|
||||||
except ClanCmdError as e:
|
except ClanCmdError as e:
|
||||||
print(f"Failed to update {entry.flake.flake_url}: {e}")
|
print(f"Failed to update {entry.flake.flake_url}: {e}")
|
||||||
continue
|
continue
|
||||||
@@ -31,7 +31,7 @@ def update_history() -> list[HistoryEntry]:
|
|||||||
machine_name=entry.flake.flake_attr,
|
machine_name=entry.flake.flake_attr,
|
||||||
)
|
)
|
||||||
flake = inspect_flake(uri.get_url(), uri.machine_name)
|
flake = inspect_flake(uri.get_url(), uri.machine_name)
|
||||||
flake.flake_url = str(flake.flake_url)
|
flake.flake_url = flake.flake_url
|
||||||
entry = HistoryEntry(
|
entry = HistoryEntry(
|
||||||
flake=flake, last_used=datetime.datetime.now().isoformat()
|
flake=flake, last_used=datetime.datetime.now().isoformat()
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ def test_history_add(
|
|||||||
history_file = user_history_file()
|
history_file = user_history_file()
|
||||||
assert history_file.exists()
|
assert history_file.exists()
|
||||||
history = [HistoryEntry(**entry) for entry in json.loads(open(history_file).read())]
|
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
|
@pytest.mark.impure
|
||||||
|
|||||||
@@ -163,12 +163,12 @@ class ClanStore:
|
|||||||
del self.clan_store[str(vm.data.flake.flake_url)][vm.data.flake.flake_attr]
|
del self.clan_store[str(vm.data.flake.flake_url)][vm.data.flake.flake_attr]
|
||||||
|
|
||||||
def get_vm(self, uri: ClanURI) -> None | VMObject:
|
def get_vm(self, uri: ClanURI) -> None | VMObject:
|
||||||
flake_id = Machine(uri.machine_name, uri.flake).get_id()
|
machine = Machine(uri.machine_name, uri.flake)
|
||||||
vm_store = self.clan_store.get(flake_id)
|
vm_store = self.clan_store.get(str(machine.flake))
|
||||||
if vm_store is None:
|
if vm_store is None:
|
||||||
return None
|
return None
|
||||||
machine = vm_store.get(uri.machine_name, None)
|
vm = vm_store.get(str(machine.name), None)
|
||||||
return machine
|
return vm
|
||||||
|
|
||||||
def get_running_vms(self) -> list[VMObject]:
|
def get_running_vms(self) -> list[VMObject]:
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ let
|
|||||||
libadwaita
|
libadwaita
|
||||||
webkitgtk_6_0
|
webkitgtk_6_0
|
||||||
adwaita-icon-theme
|
adwaita-icon-theme
|
||||||
];
|
] ++ clan-cli.propagatedBuildInputs;
|
||||||
|
|
||||||
# Deps including python packages from the local project
|
# Deps including python packages from the local project
|
||||||
allPythonDeps = [ (python3.pkgs.toPythonModule clan-cli) ] ++ externalPythonDeps;
|
allPythonDeps = [ (python3.pkgs.toPythonModule clan-cli) ] ++ externalPythonDeps;
|
||||||
@@ -84,7 +84,6 @@ python3.pkgs.buildPythonApplication rec {
|
|||||||
setuptools
|
setuptools
|
||||||
copyDesktopItems
|
copyDesktopItems
|
||||||
wrapGAppsHook
|
wrapGAppsHook
|
||||||
|
|
||||||
gobject-introspection
|
gobject-introspection
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -93,14 +92,7 @@ python3.pkgs.buildPythonApplication rec {
|
|||||||
# that all necessary dependencies are consistently available both
|
# that all necessary dependencies are consistently available both
|
||||||
# at build time and runtime,
|
# at build time and runtime,
|
||||||
buildInputs = allPythonDeps ++ runtimeDependencies;
|
buildInputs = allPythonDeps ++ runtimeDependencies;
|
||||||
propagatedBuildInputs =
|
propagatedBuildInputs = allPythonDeps ++ runtimeDependencies ++ [ ];
|
||||||
allPythonDeps
|
|
||||||
++ runtimeDependencies
|
|
||||||
++ [
|
|
||||||
|
|
||||||
# TODO: see postFixup clan-cli/default.nix:L188
|
|
||||||
clan-cli.propagatedBuildInputs
|
|
||||||
];
|
|
||||||
|
|
||||||
# also re-expose dependencies so we test them in CI
|
# also re-expose dependencies so we test them in CI
|
||||||
passthru = {
|
passthru = {
|
||||||
|
|||||||
Reference in New Issue
Block a user