From 195134dd5e2d03a9fa5d2e130abb20220617de06 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 5 Jul 2025 19:48:38 +0200 Subject: [PATCH] clan_cli: better select debug output --- pkgs/clan-cli/clan_lib/flake/flake.py | 31 +++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/pkgs/clan-cli/clan_lib/flake/flake.py b/pkgs/clan-cli/clan_lib/flake/flake.py index 529207860..2d82a8acb 100644 --- a/pkgs/clan-cli/clan_lib/flake/flake.py +++ b/pkgs/clan-cli/clan_lib/flake/flake.py @@ -730,7 +730,7 @@ class Flake: ClanError: If the number of outputs does not match the number of selectors. AssertionError: If the cache or flake cache path is not properly initialized. """ - from clan_lib.cmd import Log, RunOpts, run + from clan_lib.cmd import run, RunOpts, Log from clan_lib.dirs import select_source from clan_lib.nix import ( nix_build, @@ -796,11 +796,38 @@ class Flake: ]; }} """ + if len(selectors) > 1: + log.debug(f""" +selecting: {selectors} +to debug run: +nix repl --expr 'rec {{ + flake = builtins.getFlake "self.identifier"; + selectLib = (builtins.getFlake "path:{select_source()}?narHash={select_hash}").lib; + query = [ + {" ".join( + [ + f"(selectLib.select ''{selector}'' flake)" + for selector in selectors + ] + )} + ]; +}}' + """) # fmt: on + elif len(selectors) == 1: + log.debug(f""" +selecting: {selectors[0]} +to debug run: +nix repl --expr 'rec {{ + flake = builtins.getFlake "{self.identifier}"; + selectLib = (builtins.getFlake "path:{select_source()}?narHash={select_hash}").lib; + query = selectLib.select '"''{selectors[0]}''"' flake; +}}' + """) build_output = Path( run( - nix_build(["--expr", nix_code, *nix_options]), RunOpts(log=Log.NONE) + nix_build(["--expr", nix_code, *nix_options]), RunOpts(log=Log.NONE, trace=False), ).stdout.strip() )