From 8360ee58b5fcf87998e0c217f9270dbfabc37c83 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Mon, 9 Jun 2025 20:40:20 +0200 Subject: [PATCH] chore(flake): move 'inputs-from' into templates handling --- pkgs/clan-cli/clan_lib/flake/flake.py | 4 ---- pkgs/clan-cli/clan_lib/templates/__init__.py | 21 ++++++++++++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/pkgs/clan-cli/clan_lib/flake/flake.py b/pkgs/clan-cli/clan_lib/flake/flake.py index 20675ab6f..a2dd85cf8 100644 --- a/pkgs/clan-cli/clan_lib/flake/flake.py +++ b/pkgs/clan-cli/clan_lib/flake/flake.py @@ -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"] diff --git a/pkgs/clan-cli/clan_lib/templates/__init__.py b/pkgs/clan-cli/clan_lib/templates/__init__.py index ca4ef673c..6e880ec7a 100644 --- a/pkgs/clan-cli/clan_lib/templates/__init__.py +++ b/pkgs/clan-cli/clan_lib/templates/__init__.py @@ -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(