Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/nethermind/nix-update-args

This file was deleted.

3 changes: 1 addition & 2 deletions packages/nethermind/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
fetchFromGitHub,
lib,
lz4,
nix-update-script,
rocksdb,
snappy,
stdenv,
Expand Down Expand Up @@ -48,7 +47,7 @@ buildDotnetModule rec {

passthru = {
category = "Execution Clients";
updateScript = nix-update-script { };
updateScript = ./update.py;
};

meta = {
Expand Down
73 changes: 73 additions & 0 deletions packages/nethermind/update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env nix-shell
#!nix-shell -i python3 -p python3 nix-update
"""Update script for nethermind package.

nix-update handles version and source hash but cannot update nuget-deps.json.
This script runs nix-update first, then uses the package's fetch-deps script
to regenerate nuget-deps.json.
"""

import subprocess
import sys
from pathlib import Path

SCRIPT_DIR = Path(__file__).parent
FLAKE_ROOT = SCRIPT_DIR.parent.parent
NUGET_DEPS = SCRIPT_DIR / "nuget-deps.json"


def run_nix_update() -> bool:
"""Run nix-update to handle version and source hash."""
print("Running nix-update...")
result = subprocess.run(
[
"nix-update",
"--flake",
"nethermind",
"--version-regex",
"^([0-9]+\\.[0-9]+\\.[0-9]+)$",
# https://github.com/Mic92/nix-update/issues/563
"--src-only",
],
cwd=FLAKE_ROOT,
)
return result.returncode == 0


def update_nuget_deps() -> None:
"""Regenerate nuget-deps.json using the package's fetch-deps script."""
print("Building fetch-deps script...")
result = subprocess.run(
[
"nix",
"build",
".#nethermind.fetch-deps",
"--no-link",
"--print-out-paths",
],
capture_output=True,
text=True,
check=True,
cwd=FLAKE_ROOT,
)
fetch_deps_script = result.stdout.strip()

print("Regenerating nuget-deps.json...")
subprocess.run(
[fetch_deps_script, str(NUGET_DEPS)],
check=True,
cwd=FLAKE_ROOT,
)


def main() -> None:
if not run_nix_update():
print("nix-update failed")
sys.exit(1)

update_nuget_deps()
print("Done")


if __name__ == "__main__":
main()