Merge pull request 'modules/inventory: use filtered serialization of inventory instead' (#5634) from modules-1 into main

Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/5634
This commit is contained in:
hsjobeki
2025-10-23 12:14:48 +00:00
6 changed files with 13 additions and 11 deletions

6
devFlake/flake.lock generated
View File

@@ -3,10 +3,10 @@
"clan-core-for-checks": { "clan-core-for-checks": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1760361585, "lastModified": 1761204206,
"narHash": "sha256-v4PnSmt1hXW4dSgVWxcd1ZeEBlhO7NksNRC5cX7L5iw=", "narHash": "sha256-A4KDudGblln1yh8c95OVow2NRlHtbGZXr/pgNenyrNc=",
"ref": "main", "ref": "main",
"rev": "7e7e58eb64ef61beb0a938a6622ec0122382131b", "rev": "aabbe0dfac47b7cfbe2210bcb27fb7ecce93350f",
"shallow": true, "shallow": true,
"type": "git", "type": "git",
"url": "https://git.clan.lol/clan/clan-core" "url": "https://git.clan.lol/clan/clan-core"

View File

@@ -241,9 +241,9 @@ def test_caching_works(flake: ClanFlake) -> None:
wraps=my_flake.get_from_nix, wraps=my_flake.get_from_nix,
) as tracked_build: ) as tracked_build:
assert tracked_build.call_count == 0 assert tracked_build.call_count == 0
my_flake.select("clanInternals.inventoryClass.inventory.meta") my_flake.select("clanInternals.inventoryClass.inventorySerialization.meta")
assert tracked_build.call_count == 1 assert tracked_build.call_count == 1
my_flake.select("clanInternals.inventoryClass.inventory.meta") my_flake.select("clanInternals.inventoryClass.inventorySerialization.meta")
assert tracked_build.call_count == 1 assert tracked_build.call_count == 1

View File

@@ -22,7 +22,7 @@ let
}; };
in in
{ {
clanInternals.inventoryClass.inventory = eval.config; clanInternals.inventoryClass.inventorySerialization = eval.config;
clanInternals.inventoryClass.introspection = clanLib.introspection.getPrios { clanInternals.inventoryClass.introspection = clanLib.introspection.getPrios {
options = eval.options; options = eval.options;
}; };

View File

@@ -25,7 +25,7 @@ let
}; };
in in
{ {
clanInternals.inventoryClass.inventory = eval.config; clanInternals.inventoryClass.inventorySerialization = eval.config;
clanInternals.inventoryClass.introspection = clanLib.introspection.getPrios { clanInternals.inventoryClass.introspection = clanLib.introspection.getPrios {
options = eval.options; options = eval.options;
}; };

View File

@@ -25,7 +25,7 @@ let
}; };
in in
{ {
clanInternals.inventoryClass.inventory = eval.config; clanInternals.inventoryClass.inventorySerialization = eval.config;
clanInternals.inventoryClass.introspection = clanLib.introspection.getPrios { clanInternals.inventoryClass.introspection = clanLib.introspection.getPrios {
options = eval.options; options = eval.options;
}; };

View File

@@ -138,7 +138,7 @@ class InventoryStore:
@classmethod @classmethod
def default_selectors(cls) -> list[str]: def default_selectors(cls) -> list[str]:
return [ return [
f"clanInternals.inventoryClass.inventory.{key}" f"clanInternals.inventoryClass.inventorySerialization.{key}"
for key in cls.default_keys() for key in cls.default_keys()
] ]
@@ -146,7 +146,7 @@ class InventoryStore:
"""Loads the evaluated inventory. """Loads the evaluated inventory.
After all merge operations with eventual nix code in buildClan. After all merge operations with eventual nix code in buildClan.
Evaluates clanInternals.inventoryClass.inventory with nix. Which is performant. Evaluates clanInternals.inventoryClass.inventorySerialization with nix. Which is performant.
- Contains all clan metadata - Contains all clan metadata
- Contains all machines - Contains all machines
@@ -164,7 +164,9 @@ class InventoryStore:
def get_readonly_raw(self, keys: set[str]) -> Inventory: def get_readonly_raw(self, keys: set[str]) -> Inventory:
attrs = "{" + ",".join(sorted(keys)) + "}" attrs = "{" + ",".join(sorted(keys)) + "}"
return self._flake.select(f"clanInternals.inventoryClass.inventory.{attrs}") return self._flake.select(
f"clanInternals.inventoryClass.inventorySerialization.{attrs}"
)
def _get_persisted(self) -> InventorySnapshot: def _get_persisted(self) -> InventorySnapshot:
"""Load the inventory FILE from the flake directory """Load the inventory FILE from the flake directory