add flake evaluator, make hydraJob outputs optional
Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
This commit is contained in:
25
flupdt/flake_eval.py
Normal file
25
flupdt/flake_eval.py
Normal file
@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import logging
|
||||
from typing import Optional
|
||||
from flupdt.common import bash_wrapper
|
||||
import re
|
||||
|
||||
drv_re = re.compile(r'.*(/nix/store/.*\.drv).*')
|
||||
|
||||
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])
|
||||
logging.debug(out[1])
|
||||
logging.debug(out[2])
|
||||
if out[2] != 0:
|
||||
logging.warning(f"output {output} did not evaluate correctly")
|
||||
return None
|
||||
else:
|
||||
drv_match = drv_re.match(out[0])
|
||||
if drv_match is None:
|
||||
out_msg = "derivation succeeded but output derivation does not contain a derivation"
|
||||
raise RuntimeError(out_msg)
|
||||
drv = drv_match.group(1)
|
||||
logging.debug(f"derivation evaluated to {drv}")
|
Reference in New Issue
Block a user