diff --git a/pkgs/clan-app/ui/src/components/Sidebar/SidebarBody.tsx b/pkgs/clan-app/ui/src/components/Sidebar/SidebarBody.tsx
index 47182330f..9ad81d549 100644
--- a/pkgs/clan-app/ui/src/components/Sidebar/SidebarBody.tsx
+++ b/pkgs/clan-app/ui/src/components/Sidebar/SidebarBody.tsx
@@ -3,7 +3,7 @@ import { A } from "@solidjs/router";
import { Accordion } from "@kobalte/core/accordion";
import Icon from "../Icon/Icon";
import { Typography } from "@/src/components/Typography/Typography";
-import { For, Show, useContext } from "solid-js";
+import { For, Show } from "solid-js";
import { MachineStatus } from "@/src/components/MachineStatus/MachineStatus";
import { buildMachinePath, useClanURI } from "@/src/hooks/clan";
import { useMachineStateQuery } from "@/src/hooks/queries";
@@ -136,7 +136,7 @@ export const SidebarBody = (props: SidebarProps) => {
)}
diff --git a/pkgs/clan-app/ui/src/workflows/AddMachine/AddMachine.stories.tsx b/pkgs/clan-app/ui/src/workflows/AddMachine/AddMachine.stories.tsx
index f1942c717..fef1ebec6 100644
--- a/pkgs/clan-app/ui/src/workflows/AddMachine/AddMachine.stories.tsx
+++ b/pkgs/clan-app/ui/src/workflows/AddMachine/AddMachine.stories.tsx
@@ -26,13 +26,19 @@ const mockFetcher: Fetcher = (
const resultData: Partial = {
list_machines: {
pandora: {
- name: "pandora",
+ data: {
+ name: "pandora",
+ },
},
enceladus: {
- name: "enceladus",
+ data: {
+ name: "enceladus",
+ },
},
dione: {
- name: "dione",
+ data: {
+ name: "dione",
+ },
},
},
};
diff --git a/pkgs/clan-app/ui/src/workflows/Service/Service.stories.tsx b/pkgs/clan-app/ui/src/workflows/Service/Service.stories.tsx
index 92359c054..663a158c8 100644
--- a/pkgs/clan-app/ui/src/workflows/Service/Service.stories.tsx
+++ b/pkgs/clan-app/ui/src/workflows/Service/Service.stories.tsx
@@ -62,20 +62,28 @@ const mockFetcher: Fetcher = (
},
list_machines: {
jon: {
- name: "jon",
- tags: ["all", "nixos", "tag1"],
+ data: {
+ name: "jon",
+ tags: ["all", "nixos", "tag1"],
+ },
},
sara: {
- name: "sara",
- tags: ["all", "darwin", "tag2"],
+ data: {
+ name: "sara",
+ tags: ["all", "darwin", "tag2"],
+ },
},
kyra: {
- name: "kyra",
- tags: ["all", "darwin", "tag2"],
+ data: {
+ name: "kyra",
+ tags: ["all", "darwin", "tag2"],
+ },
},
leila: {
- name: "leila",
- tags: ["all", "darwin", "tag2"],
+ data: {
+ name: "leila",
+ tags: ["all", "darwin", "tag2"],
+ },
},
},
list_tags: {
diff --git a/pkgs/clan-app/ui/src/workflows/Service/Service.tsx b/pkgs/clan-app/ui/src/workflows/Service/Service.tsx
index 59f913b9e..d7f04bb96 100644
--- a/pkgs/clan-app/ui/src/workflows/Service/Service.tsx
+++ b/pkgs/clan-app/ui/src/workflows/Service/Service.tsx
@@ -120,7 +120,7 @@ const SelectService = () => {
label: t,
type: "tag" as const,
members: Object.entries(machinesQuery.data || {})
- .filter(([_, m]) => m.tags?.includes(t))
+ .filter(([_, m]) => m.data.tags?.includes(t))
.map(([k]) => k),
};
});
@@ -206,7 +206,7 @@ const useOptions = (tagsQuery: TagsQuery, machinesQuery: MachinesQuery) =>
label: tag,
value: "t_" + tag,
members: Object.entries(machines)
- .filter(([_, v]) => v.tags?.includes(tag))
+ .filter(([_, v]) => v.data.tags?.includes(tag))
.map(([k]) => k),
}));
diff --git a/pkgs/clan-cli/clan_cli/machines/update.py b/pkgs/clan-cli/clan_cli/machines/update.py
index eb274e3e6..57a4cb889 100644
--- a/pkgs/clan-cli/clan_cli/machines/update.py
+++ b/pkgs/clan-cli/clan_cli/machines/update.py
@@ -103,7 +103,9 @@ def get_machines_for_update(
machines_to_update = list(
filter(
requires_explicit_update,
- instantiate_inventory_to_machines(flake, machines_with_tags).values(),
+ instantiate_inventory_to_machines(
+ flake, {name: m.data for name, m in machines_with_tags.items()}
+ ).values(),
),
)
# all machines that are in the clan but not included in the update list
@@ -128,13 +130,13 @@ def get_machines_for_update(
machines_to_update = []
valid_names = validate_machine_names(explicit_names, flake)
for name in valid_names:
- inventory_machine = machines_with_tags.get(name)
- if not inventory_machine:
+ machine = machines_with_tags.get(name)
+ if not machine:
msg = "This is an internal bug"
raise ClanError(msg)
machines_to_update.append(
- Machine.from_inventory(name, flake, inventory_machine),
+ Machine.from_inventory(name, flake, machine.data),
)
return machines_to_update
diff --git a/pkgs/clan-cli/clan_lib/machines/actions.py b/pkgs/clan-cli/clan_lib/machines/actions.py
index fd7212b5f..fc6f9a373 100644
--- a/pkgs/clan-cli/clan_lib/machines/actions.py
+++ b/pkgs/clan-cli/clan_lib/machines/actions.py
@@ -41,28 +41,34 @@ class MachineState(TypedDict):
# add more info later when retrieving remote state
+@dataclass
+class MachineResponse:
+ data: InventoryMachine
+ # Reference the installed service instances
+ instance_refs: list[str] = field(default_factory=list)
+
+
@API.register
def list_machines(
flake: Flake,
opts: ListOptions | None = None,
-) -> dict[str, InventoryMachine]:
+) -> dict[str, MachineResponse]:
"""List machines of a clan"""
inventory_store = InventoryStore(flake=flake)
inventory = inventory_store.read()
- machines = inventory.get("machines", {})
+ raw_machines = inventory.get("machines", {})
- if opts and opts.filter.tags is not None:
- filtered_machines = {}
-
- for machine_name, machine in machines.items():
+ res: dict[str, MachineResponse] = {}
+ for machine_name, machine in raw_machines.items():
+ if opts and opts.filter.tags is not None:
machine_tags = machine.get("tags", [])
if all(ft in machine_tags for ft in opts.filter.tags):
- filtered_machines[machine_name] = machine
+ res[machine_name] = MachineResponse(data=InventoryMachine(**machine))
+ else:
+ res[machine_name] = MachineResponse(data=InventoryMachine(**machine))
- return filtered_machines
-
- return machines
+ return res
@API.register
diff --git a/pkgs/clan-cli/clan_lib/machines/list.py b/pkgs/clan-cli/clan_lib/machines/list.py
index b80ddbd4a..17ee2f412 100644
--- a/pkgs/clan-cli/clan_lib/machines/list.py
+++ b/pkgs/clan-cli/clan_lib/machines/list.py
@@ -30,7 +30,9 @@ def list_full_machines(flake: Flake) -> dict[str, Machine]:
"""Like `list_machines`, but returns a full 'machine' instance for each machine."""
machines = list_machines(flake)
- return instantiate_inventory_to_machines(flake, machines)
+ return instantiate_inventory_to_machines(
+ flake, {name: m.data for name, m in machines.items()}
+ )
@dataclass