clan_cli flake: remove apply from select, as it will break stuff in horrible ways

Since apply changes the structure of the retuned value, the cache will
be confused about the structure and in subsequent request will use this
wrong structure.

For example: we would use builtins.attrNames on inputs, the flake will
forever think that inputs is a list of strings and will report errors
whenever we try to fetch subkeys from it
This commit is contained in:
lassulus
2025-07-06 00:48:26 +02:00
parent 8bbee566fc
commit af33f122b0

View File

@@ -621,7 +621,9 @@ class Flake:
return self._is_local return self._is_local
def get_input_names(self) -> list[str]: def get_input_names(self) -> list[str]:
return self.select("inputs", apply="builtins.attrNames") log.debug("flake.get_input_names is deprecated and will be removed")
flakes = self.select("inputs.*._type")
return list(flakes.keys())
@property @property
def path(self) -> Path: def path(self) -> Path:
@@ -710,7 +712,6 @@ class Flake:
def get_from_nix( def get_from_nix(
self, self,
selectors: list[str], selectors: list[str],
apply: str = "v: v",
) -> None: ) -> None:
""" """
Retrieves specific attributes from a Nix flake using the provided selectors. Retrieves specific attributes from a Nix flake using the provided selectors.
@@ -772,7 +773,7 @@ class Flake:
result = builtins.toJSON [ result = builtins.toJSON [
{" ".join( {" ".join(
[ [
f"(({apply}) (selectLib.applySelectors (builtins.fromJSON ''{attr}'') flake))" f"(selectLib.applySelectors (builtins.fromJSON ''{attr}'') flake)"
for attr in str_selectors for attr in str_selectors
] ]
)} )}
@@ -840,7 +841,6 @@ class Flake:
def select( def select(
self, self,
selector: str, selector: str,
apply: str = "v: v",
) -> Any: ) -> Any:
""" """
Selects a value from the cache based on the provided selector string. Selects a value from the cache based on the provided selector string.
@@ -856,6 +856,6 @@ class Flake:
if not self._cache.is_cached(selector): if not self._cache.is_cached(selector):
log.debug(f"Cache miss for {selector}") log.debug(f"Cache miss for {selector}")
self.get_from_nix([selector], apply=apply) self.get_from_nix([selector])
value = self._cache.select(selector) value = self._cache.select(selector)
return value return value