chore(flake): move 'inputs-from' into templates handling

This commit is contained in:
Johannes Kirschbauer
2025-06-09 20:40:20 +02:00
parent 217df6b98c
commit ca8a228fba
2 changed files with 17 additions and 8 deletions

View File

@@ -568,7 +568,6 @@ class Flake:
"""
identifier: str
inputs_from: str | None = None
hash: str | None = None
store_path: str | None = None
@@ -634,9 +633,6 @@ class Flake:
self.identifier,
]
if self.inputs_from:
cmd += ["--inputs-from", self.inputs_from]
flake_prefetch = run(nix_command(cmd))
flake_metadata = json.loads(flake_prefetch.stdout)
self.store_path = flake_metadata["storePath"]

View File

@@ -7,6 +7,9 @@ from clan_lib.cmd import run
from clan_lib.dirs import clan_templates
from clan_lib.errors import ClanCmdError, ClanError
from clan_lib.flake import Flake
from clan_lib.nix import (
nix_command,
)
log = logging.getLogger(__name__)
@@ -202,16 +205,26 @@ def list_templates(
return result
def realize_nix_path(clan_dir: Flake, nix_path: str) -> None:
def realize_nix_path(flake: Flake, nix_store_path: str) -> None:
"""
Downloads / realizes a nix path into the nix store
"""
if Path(nix_path).exists():
if Path(nix_store_path).exists():
return
flake = Flake(identifier=nix_path, inputs_from=clan_dir.identifier)
flake.invalidate_cache()
cmd = [
"flake",
"prefetch",
"--inputs-from",
flake.identifier,
"--option",
"flake-registry",
"",
nix_store_path,
]
run(nix_command(cmd))
def get_template(