Added clan flakes inspect command. Improved ClanURI. Added democlan as dependency in flake.nix

This commit is contained in:
Qubasa
2023-12-09 00:04:56 +01:00
parent 91ca79be0d
commit 4506202a82
14 changed files with 406 additions and 41 deletions

View File

@@ -10,7 +10,6 @@ from .dirs import nixpkgs_flake, nixpkgs_source
from .errors import ClanError
@deal.raises(ClanError)
def nix_command(flags: list[str]) -> list[str]:
return ["nix", "--extra-experimental-features", "nix-command flakes", *flags]
@@ -28,7 +27,6 @@ def nix_flake_show(flake_url: str | Path) -> list[str]:
)
@deal.raises(ClanError)
def nix_build(
flags: list[str],
) -> list[str]:
@@ -45,7 +43,6 @@ def nix_build(
)
@deal.raises(ClanError)
def nix_config() -> dict[str, Any]:
cmd = nix_command(["show-config", "--json"])
proc = subprocess.run(cmd, check=True, text=True, stdout=subprocess.PIPE)
@@ -56,7 +53,6 @@ def nix_config() -> dict[str, Any]:
return config
@deal.raises(ClanError)
def nix_eval(flags: list[str]) -> list[str]:
default_flags = nix_command(
[
@@ -82,9 +78,8 @@ def nix_eval(flags: list[str]) -> list[str]:
return default_flags + flags
@deal.raises(ClanError)
def nix_metadata(flake: str) -> dict[str, Any]:
cmd = nix_command(["flake", "metadata", "--json", flake])
def nix_metadata(flake_url: str | Path) -> dict[str, Any]:
cmd = nix_command(["flake", "metadata", "--json", f"{flake_url}"])
proc = subprocess.run(cmd, check=True, text=True, stdout=subprocess.PIPE)
data = json.loads(proc.stdout)
return data