feature/flupdt #1

Merged
ahuston-0 merged 14 commits from feature/flupdt into main 2025-03-02 01:01:15 -05:00
3 changed files with 21 additions and 14 deletions
Showing only changes of commit 39a57188b5 - Show all commits

View File

@ -4,17 +4,17 @@
nixConfig = {
substituters = [
"https://cache.nixos.org/?priority=1&want-mass-query=true"
"https://attic.alicehuston.xyz/cache-nix-dot?priority=4&want-mass-query=true"
"https://attic.nayeonie.com/nix-cache"
"https://nix-community.cachix.org/?priority=10&want-mass-query=true"
];
trusted-substituters = [
"https://cache.nixos.org"
"https://attic.alicehuston.xyz/cache-nix-dot"
"https://attic.nayeonie.com/nix-cache"
"https://nix-community.cachix.org"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"cache-nix-dot:Od9KN34LXc6Lu7y1ozzV1kIXZa8coClozgth/SYE7dU="
"nix-cache:trR+y5nwpQHR4hystoogubFmp97cewkjWeqqbygRQRs="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};

View File

@ -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
ahuston-0 marked this conversation as resolved Outdated

this should be common.py

this should be common.py
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])

View File

@ -7,11 +7,16 @@ import logging
import rad_development_python as rd
ahuston-0 marked this conversation as resolved Outdated

should be common.py

should be common.py
def main():
def main() -> None:
"""Sets up logging, parses args, and runs evaluation routine.
:returns: None
"""
rd.configure_logger("INFO")
args = parse_inputs()
flake_path = args.flake_path
derivations, hydraJobs = rd.partition(
derivations, hydra_jobs = rd.partition(
lambda s: s.startswith("hydraJobs"), get_derivations(flake_path)
)
logging.info(f"derivations: {list(derivations)}")
@ -21,8 +26,8 @@ def main():
if not args.keep_hydra:
logging.info("--keep-hydra flag is not specified, removing Hydra jobs")
else:
logging.info(f"hydraJobs: {list(hydraJobs)}")
for d in hydraJobs:
logging.info(f"hydraJobs: {list(hydra_jobs)}")
for d in hydra_jobs:
evaluate_output(flake_path, d)