add rad_development_python to environment and add update instructions
This commit is contained in:
@ -8,7 +8,7 @@ def parse_inputs():
|
||||
"flake_path", metavar="flake-path", help="path to flake to evaluate"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--keep-hydra", action="store_true",help="allow evaluating Hydra jobs"
|
||||
"--keep-hydra", action="store_true", help="allow evaluating Hydra jobs"
|
||||
)
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
|
@ -5,9 +5,10 @@ from typing import Optional
|
||||
from flupdt.common import bash_wrapper
|
||||
import re
|
||||
|
||||
drv_re = re.compile(r'.*(/nix/store/.*\.drv).*')
|
||||
drv_re = re.compile(r".*(/nix/store/.*\.drv).*")
|
||||
|
||||
def evaluate_output(path:str, output: str) -> Optional[str]:
|
||||
|
||||
def evaluate_output(path: str, output: str) -> Optional[str]:
|
||||
logging.info(f"evaluating {output}")
|
||||
out = bash_wrapper(f"nix eval {path}#{output}")
|
||||
logging.debug(out[0])
|
||||
|
@ -7,8 +7,8 @@ import logging
|
||||
import re
|
||||
|
||||
output_regexes = [
|
||||
re.compile(r'checking derivation (.*)...'),
|
||||
re.compile(r'checking NixOS configuration \'(nixosConfigurations.*)\'\.\.\.')
|
||||
re.compile(r"checking derivation (.*)..."),
|
||||
re.compile(r"checking NixOS configuration \'(nixosConfigurations.*)\'\.\.\."),
|
||||
]
|
||||
|
||||
|
||||
@ -31,11 +31,16 @@ def traverse_json_base(json_dict: dict, path: list[str]) -> list[str]:
|
||||
def traverse_json(json_dict: dict) -> list[str]:
|
||||
return traverse_json_base(json_dict, [])
|
||||
|
||||
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)
|
||||
|
||||
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("nix flake check returned non-zero exit code, collecting all available outputs")
|
||||
error_out = flake_check[1].split('\n')
|
||||
logging.warn(
|
||||
"nix flake check returned non-zero exit code, collecting all available outputs"
|
||||
)
|
||||
error_out = flake_check[1].split("\n")
|
||||
possible_outputs = filter(lambda s: s.startswith("checking"), error_out)
|
||||
derivations = []
|
||||
for output in possible_outputs:
|
||||
@ -47,20 +52,23 @@ def get_derivations_from_check(nix_path:str,path_to_flake:str)-> list[str]:
|
||||
derivations += [match.groups()[0]]
|
||||
return derivations
|
||||
|
||||
|
||||
def get_derivations(path_to_flake: str) -> list[str]:
|
||||
nix_path = shutil.which("nix")
|
||||
derivations = []
|
||||
if nix_path is None:
|
||||
raise RuntimeError("nix is not available in the PATH, please verify that it is installed")
|
||||
raise RuntimeError(
|
||||
"nix is not available in the PATH, please verify that it is installed"
|
||||
)
|
||||
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")
|
||||
derivations = get_derivations_from_check(nix_path, path_to_flake)
|
||||
derivations = get_derivations_from_check(nix_path, path_to_flake)
|
||||
else:
|
||||
flake_show_json = json.loads(flake_show[0])
|
||||
derivations = traverse_json(flake_show_json)
|
||||
for i in range(len(derivations)):
|
||||
if derivations[i].startswith("nixosConfigurations"):
|
||||
derivations[i] += ".config.system.build.toplevel"
|
||||
derivations[i] += ".config.system.build.toplevel"
|
||||
return derivations
|
||||
|
@ -5,13 +5,19 @@ from flupdt.cli import parse_inputs
|
||||
from flupdt.flake_eval import evaluate_output
|
||||
from flupdt.common import configure_logger
|
||||
import logging
|
||||
import rad_development_python as rd
|
||||
|
||||
|
||||
def main():
|
||||
configure_logger("INFO")
|
||||
rd.configure_logger("INFO")
|
||||
args = parse_inputs()
|
||||
print("hi")
|
||||
flake_path = args.flake_path
|
||||
derivations = get_derivations(flake_path)
|
||||
if not args.keep_hydra and len(list(filter(lambda s: s.startswith("hydraJobs"), derivations))) > 0:
|
||||
if (
|
||||
not args.keep_hydra
|
||||
and len(list(filter(lambda s: s.startswith("hydraJobs"), derivations))) > 0
|
||||
):
|
||||
logging.info("--keep-hydra flag is not specified, removing Hydra jobs")
|
||||
derivations = filter(lambda s: not s.startswith("hydraJobs"), derivations)
|
||||
logging.info(f"derivations: {list(derivations)}")
|
||||
|
Reference in New Issue
Block a user