switch to new cache, fix minor issues with logging
This commit is contained in:
@ -1,10 +1,12 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import json
|
||||
from rad_development_python import bash_wrapper
|
||||
import shutil
|
||||
import logging
|
||||
import re
|
||||
import shutil
|
||||
import typing
|
||||
|
||||
from rad_development_python import bash_wrapper
|
||||
|
||||
output_regexes = [
|
||||
re.compile(r"checking derivation (.*)..."),
|
||||
@ -12,7 +14,7 @@ output_regexes = [
|
||||
]
|
||||
|
||||
|
||||
def traverse_json_base(json_dict: dict, path: list[str]) -> list[str]:
|
||||
def traverse_json_base(json_dict: dict[str,typing.Any], path: list[str]) -> list[str]:
|
||||
final_paths = []
|
||||
for key, value in json_dict.items():
|
||||
if isinstance(value, dict):
|
||||
@ -21,10 +23,10 @@ def traverse_json_base(json_dict: dict, path: list[str]) -> list[str]:
|
||||
"nixos-configuration",
|
||||
"derivation",
|
||||
]:
|
||||
output = ".".join(path + [key])
|
||||
output = ".".join([*path, key])
|
||||
final_paths += [output]
|
||||
else:
|
||||
final_paths += traverse_json_base(value, path + [key])
|
||||
final_paths += traverse_json_base(value, [*path ,key])
|
||||
return final_paths
|
||||
|
||||
|
||||
@ -35,7 +37,7 @@ def traverse_json(json_dict: dict) -> list[str]:
|
||||
def get_derivations_from_check(nix_path: str, path_to_flake: str) -> list[str]:
|
||||
flake_check = bash_wrapper(f"{nix_path} flake check --verbose --keep-going", path=path_to_flake)
|
||||
if flake_check[2] != 0:
|
||||
logging.warn(
|
||||
logging.warning(
|
||||
"nix flake check returned non-zero exit code, collecting all available outputs"
|
||||
)
|
||||
error_out = flake_check[1].split("\n")
|
||||
@ -59,7 +61,7 @@ def get_derivations(path_to_flake: str) -> list[str]:
|
||||
flake_show = bash_wrapper(f"{nix_path} flake show --json", path=path_to_flake)
|
||||
if flake_show[2] != 0:
|
||||
logging.error("flake show returned non-zero exit code")
|
||||
logging.warn("falling back to full evaluation via nix flake check")
|
||||
logging.warning("falling back to full evaluation via nix flake check")
|
||||
derivations = get_derivations_from_check(nix_path, path_to_flake)
|
||||
else:
|
||||
flake_show_json = json.loads(flake_show[0])
|
||||
|
Reference in New Issue
Block a user