Merge pull request 'cli: allow using commands from local flakerefs for debugging' (#3819) from push-quvsovsorszu into main

Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/3819
This commit is contained in:
Michael Hoang
2025-06-03 04:20:58 +00:00

View File

@@ -119,6 +119,13 @@ class Packages:
else: else:
allowed_packages = cls.allowed_packages allowed_packages = cls.allowed_packages
if "#" in package:
log.warning(
"Allowing package %s for debugging as it looks like a flakeref",
package,
)
return
if package not in allowed_packages: if package not in allowed_packages:
msg = f"Package not allowed: '{package}', allowed packages are:\n{'\n'.join(allowed_packages)}" msg = f"Package not allowed: '{package}', allowed packages are:\n{'\n'.join(allowed_packages)}"
raise ClanError(msg) raise ClanError(msg)
@@ -133,6 +140,9 @@ class Packages:
os.environ.get("CLAN_PROVIDED_PACKAGES", "").split(":") os.environ.get("CLAN_PROVIDED_PACKAGES", "").split(":")
) )
if "#" in program:
return True
if program in cls.static_packages: if program in cls.static_packages:
if shutil.which(program) is None: if shutil.which(program) is None:
log.warning( log.warning(
@@ -157,7 +167,7 @@ def nix_shell(packages: list[str], cmd: list[str]) -> list[str]:
f"nixpkgs#{package}" f"nixpkgs#{package}"
for package in packages for package in packages
if not Packages.is_provided(package) if not Packages.is_provided(package)
] ] + [package for package in packages if "#" in package]
if not missing_packages: if not missing_packages:
return cmd return cmd
return [ return [