feat(flake/select): add apply argument

This commit is contained in:
Johannes Kirschbauer
2025-06-11 20:05:39 +02:00
parent 799c23bb56
commit 6b684c45c3

View File

@@ -680,6 +680,7 @@ class Flake:
self, self,
selectors: list[str], selectors: list[str],
nix_options: list[str] | None = None, nix_options: list[str] | None = None,
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.
@@ -754,7 +755,7 @@ class Flake:
result = builtins.toJSON [ result = builtins.toJSON [
{" ".join( {" ".join(
[ [
f"(selectLib.applySelectors (builtins.fromJSON ''{attr}'') flake)" f"(({apply}) (selectLib.applySelectors (builtins.fromJSON ''{attr}'') flake))"
for attr in str_selectors for attr in str_selectors
] ]
)} )}
@@ -823,6 +824,7 @@ class Flake:
self, self,
selector: str, selector: str,
nix_options: list[str] | None = None, nix_options: list[str] | None = None,
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.
@@ -839,6 +841,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], nix_options) self.get_from_nix([selector], nix_options, apply=apply)
value = self._cache.select(selector) value = self._cache.select(selector)
return value return value