Skip to content

Commit

Permalink
Merge pull request #1529 from moduon/eval-build
Browse files Browse the repository at this point in the history
feat(eval): opt-in support for nix-build
  • Loading branch information
roberth authored Jul 8, 2022
2 parents e258b73 + 8698419 commit bd6b955
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion nixops/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,21 @@ def eval(
extra_flags: List[str] = [],
# Non-propagated args
stderr: Optional[TextIO] = None,
build: bool = False,
) -> Any:

exprs: List[str] = list(networkExprs)
if not networkExpr.is_flake:
exprs.append(networkExpr.network)

base_cmd: List[str] = (
["nix-build"]
if build
else ["nix-instantiate", "--eval-only", "--json", "--strict"]
)
argv: List[str] = (
["nix-instantiate", "--eval-only", "--json", "--strict", "--show-trace"]
base_cmd
+ ["--show-trace"]
+ [os.path.join(get_expr_path(), "eval-machine-info.nix")]
+ ["-I", "nixops=" + get_expr_path()]
+ [
Expand Down Expand Up @@ -124,6 +131,8 @@ def eval(

try:
ret = subprocess.check_output(argv, stderr=stderr, text=True)
if build:
return ret.strip()
return json.loads(ret)
except OSError as e:
raise Exception("unable to run ‘nix-instantiate’: {0}".format(e))
Expand Down

0 comments on commit bd6b955

Please sign in to comment.