From 0dfdddbef1fbf0843d6edd4edff0e83ff2215075 Mon Sep 17 00:00:00 2001 From: Giuliano Mega Date: Wed, 30 Oct 2024 06:05:16 -0300 Subject: [PATCH] Feature: configurable Nim upstream repo (#76) * add tunable repo URL when using NIM_COMMIT * fix docs * remove embedded single quotes from repo default * drop old upstream (if any) before adding a new one * rename NIM_REPO -> NIM_COMMIT_REPO * add new remote named "extra" if upstream already exists * remove previous "extra" remote before trying to reset it * make extra point to custom repo, upstream to nim-lang's --- README.md | 14 ++++++++++++++ scripts/build_nim.sh | 9 ++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fb1a125..e0f61a2 100644 --- a/README.md +++ b/README.md @@ -169,6 +169,20 @@ You also need to specify it when using this non-default Nim compiler version: `make -j8 NIM_COMMIT="v1.2.6" nimbus_beacon_node` +### NIM_COMMIT_REPO + +`NIM_COMMIT` will try to fetch commits from the +[status-im fork](https://github.com/status-im/Nim), followed by the +[official Nim language repo](https://github.com/nim-lang/Nim). If you want to +use a fork from somewhere else, you can set this to the repo's URL. + +`make -j8 NIM_COMMIT="4561f01" NIM_COMMIT_REPO="https://github.com/myorg/my-nim-fork"` + +As before, you will need to specify this again when using this non-default Nim +compiler version: + +`make -j8 NIM_COMMIT="4561f01" NIM_COMMIT_REPO="https://github.com/myorg/my-nim-fork" nimbus_beacon_node` + ### EXCLUDED_NIM_PACKAGES List of relative paths (incomplete ones also work) to Git submodules that diff --git a/scripts/build_nim.sh b/scripts/build_nim.sh index a0a7997..35ff95e 100755 --- a/scripts/build_nim.sh +++ b/scripts/build_nim.sh @@ -62,7 +62,14 @@ nim_needs_rebuilding() { if ! git checkout -q ${NIM_COMMIT} 2>/dev/null; then # Pay the price for a non-default NIM_COMMIT here, by fetching everything. # (This includes upstream branches and tags that might be missing from our fork.) - git remote add upstream https://github.com/nim-lang/Nim + if ! git remote | grep -q "^upstream$"; then + git remote add upstream https://github.com/nim-lang/Nim + fi + # If the user has specified a custom repo, add it here as a remote as well. + if [[ -n "${NIM_COMMIT_REPO}" ]]; then + git remote remove extra 2>/dev/null || true + git remote add extra "${NIM_COMMIT_REPO}" + fi git fetch --all --tags --quiet git checkout -q ${NIM_COMMIT} fi