From af33f122b08dce93723696f64448fc64f08cfc77 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 6 Jul 2025 00:48:26 +0200 Subject: [PATCH] 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 --- pkgs/clan-cli/clan_lib/flake/flake.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/clan-cli/clan_lib/flake/flake.py b/pkgs/clan-cli/clan_lib/flake/flake.py index 3a3b90310..529207860 100644 --- a/pkgs/clan-cli/clan_lib/flake/flake.py +++ b/pkgs/clan-cli/clan_lib/flake/flake.py @@ -621,7 +621,9 @@ class Flake: return self._is_local 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 def path(self) -> Path: @@ -710,7 +712,6 @@ class Flake: def get_from_nix( self, selectors: list[str], - apply: str = "v: v", ) -> None: """ Retrieves specific attributes from a Nix flake using the provided selectors. @@ -772,7 +773,7 @@ class Flake: result = builtins.toJSON [ {" ".join( [ - f"(({apply}) (selectLib.applySelectors (builtins.fromJSON ''{attr}'') flake))" + f"(selectLib.applySelectors (builtins.fromJSON ''{attr}'') flake)" for attr in str_selectors ] )} @@ -840,7 +841,6 @@ class Flake: def select( self, selector: str, - apply: str = "v: v", ) -> Any: """ 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): log.debug(f"Cache miss for {selector}") - self.get_from_nix([selector], apply=apply) + self.get_from_nix([selector]) value = self._cache.select(selector) return value