clan_cli: better select debug output

This commit is contained in:
lassulus
2025-07-05 19:48:38 +02:00
parent 0670f0ad32
commit 195134dd5e

View File

@@ -730,7 +730,7 @@ class Flake:
ClanError: If the number of outputs does not match the number of selectors. 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. 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.dirs import select_source
from clan_lib.nix import ( from clan_lib.nix import (
nix_build, 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 # 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( build_output = Path(
run( 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() ).stdout.strip()
) )