Skip to content

Commit 3b8bf10

Browse files
bbjubjub2494claude
andcommitted
nethermind: add update script to regenerate nuget-deps.json
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 136d905 commit 3b8bf10

File tree

3 files changed

+74
-4
lines changed

3 files changed

+74
-4
lines changed

packages/nethermind/nix-update-args

Lines changed: 0 additions & 2 deletions
This file was deleted.

packages/nethermind/package.nix

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
fetchFromGitHub,
55
lib,
66
lz4,
7-
nix-update-script,
87
rocksdb,
98
snappy,
109
stdenv,
@@ -48,7 +47,7 @@ buildDotnetModule rec {
4847

4948
passthru = {
5049
category = "Execution Clients";
51-
updateScript = nix-update-script { };
50+
updateScript = ./update.py;
5251
};
5352

5453
meta = {

packages/nethermind/update.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env nix-shell
2+
#!nix-shell -i python3 -p python3 nix-update
3+
"""Update script for nethermind package.
4+
5+
nix-update handles version and source hash but cannot update nuget-deps.json.
6+
This script runs nix-update first, then uses the package's fetch-deps script
7+
to regenerate nuget-deps.json.
8+
"""
9+
10+
import subprocess
11+
import sys
12+
from pathlib import Path
13+
14+
SCRIPT_DIR = Path(__file__).parent
15+
FLAKE_ROOT = SCRIPT_DIR.parent.parent
16+
NUGET_DEPS = SCRIPT_DIR / "nuget-deps.json"
17+
18+
19+
def run_nix_update() -> bool:
20+
"""Run nix-update to handle version and source hash."""
21+
print("Running nix-update...")
22+
result = subprocess.run(
23+
[
24+
"nix-update",
25+
"--flake",
26+
"nethermind",
27+
"--version-regex",
28+
"^([0-9]+\\.[0-9]+\\.[0-9]+)$",
29+
# https://github.com/Mic92/nix-update/issues/563
30+
"--src-only",
31+
],
32+
cwd=FLAKE_ROOT,
33+
)
34+
return result.returncode == 0
35+
36+
37+
def update_nuget_deps() -> None:
38+
"""Regenerate nuget-deps.json using the package's fetch-deps script."""
39+
print("Building fetch-deps script...")
40+
result = subprocess.run(
41+
[
42+
"nix",
43+
"build",
44+
".#nethermind.fetch-deps",
45+
"--no-link",
46+
"--print-out-paths",
47+
],
48+
capture_output=True,
49+
text=True,
50+
check=True,
51+
cwd=FLAKE_ROOT,
52+
)
53+
fetch_deps_script = result.stdout.strip()
54+
55+
print("Regenerating nuget-deps.json...")
56+
subprocess.run(
57+
[fetch_deps_script, str(NUGET_DEPS)],
58+
check=True,
59+
cwd=FLAKE_ROOT,
60+
)
61+
62+
63+
def main() -> None:
64+
if not run_nix_update():
65+
print("nix-update failed")
66+
sys.exit(1)
67+
68+
update_nuget_deps()
69+
print("Done")
70+
71+
72+
if __name__ == "__main__":
73+
main()

0 commit comments

Comments
 (0)