MCPcopy
hub / github.com/nix-community/NUR / eval_repo

Function eval_repo

ci/nur/eval.py:16–67  ·  view source on GitHub ↗
(repo: Repo, repo_path: Path)

Source from the content-addressed store, hash-verified

14
15
16async def eval_repo(repo: Repo, repo_path: Path) -> None:
17 with tempfile.TemporaryDirectory() as d:
18 eval_path = Path(d).joinpath("default.nix")
19 with open(eval_path, "w") as f:
20 f.write(
21 f"""
22 with import <nixpkgs> {{}};
23import {EVALREPO_PATH} {{
24 name = "{repo.name}";
25 url = "{repo.url}";
26 src = {repo_path.joinpath(repo.file)};
27 inherit pkgs lib;
28}}
29"""
30 )
31
32 canonicalized_eval_path = eval_path.resolve()
33 # fmt: off
34 cmd = [
35 "nix-env",
36 "-f", str(canonicalized_eval_path),
37 "-qa", "*",
38 "--meta",
39 "--xml",
40 "--allowed-uris", "https://static.rust-lang.org",
41 "--option", "restrict-eval", "true",
42 "--option", "allow-import-from-derivation", "true",
43 "--drv-path",
44 "--show-trace",
45 "-I", f"nixpkgs={nixpkgs_path()}",
46 "-I", str(repo_path),
47 "-I", str(canonicalized_eval_path),
48 "-I", str(EVALREPO_PATH),
49 ]
50 # fmt: on
51
52 env = dict(PATH=os.environ["PATH"], NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM="1")
53 proc = await asyncio.create_subprocess_exec(
54 *cmd,
55 env=env,
56 stdout=asyncio.subprocess.PIPE,
57 stderr=asyncio.subprocess.PIPE,
58 )
59 try:
60 stdout, stderr = await asyncio.wait_for(proc.communicate(), 180)
61 except TimeoutError:
62 proc.kill()
63 raise EvalError(f"evaluation for {repo.name} timed out of after 3 minutes")
64 if proc.returncode != 0:
65 raise EvalError(
66 f"{repo.name} does not evaluate:\n$ {' '.join(cmd)}\n\n{stderr.decode()}"
67 )
68
69
70async def eval_command(args: Namespace) -> None:

Callers 2

eval_commandFunction · 0.85
updateFunction · 0.85

Calls 2

nixpkgs_pathFunction · 0.85
EvalErrorClass · 0.85

Tested by

no test coverage detected