From 5be16419a160568ffc860c3bf630afef47445620 Mon Sep 17 00:00:00 2001 From: Jazz Turner-Baggs <473256+jazzz@users.noreply.github.com> Date: Fri, 26 Sep 2025 11:22:45 -0700 Subject: [PATCH] migrate nim_chat_poc to nbs --- .gitmodules | 20 +++++++++++++ Makefile | 11 +++++-- {src => examples}/nim_chat_poc.nim | 10 +++---- namble.sh | 46 ++++++++++++++++++++++++++++++ nim_chat_poc.nimble | 4 +++ vendor/blake2 | 1 + vendor/nim-protobuf-serialization | 1 + vendor/nim-sds | 1 + vendor/npeg | 1 + 9 files changed, 88 insertions(+), 7 deletions(-) rename {src => examples}/nim_chat_poc.nim (94%) create mode 100755 namble.sh create mode 160000 vendor/blake2 create mode 160000 vendor/nim-protobuf-serialization create mode 160000 vendor/nim-sds create mode 160000 vendor/npeg diff --git a/.gitmodules b/.gitmodules index 69eba32..ed6af0f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,3 +6,23 @@ url = https://github.com/waku-org/nwaku.git ignore = untracked branch = master +[submodule "vendor/nim-sds"] + path = vendor/nim-sds + url = https://github.com/jazzz/nim-sds.git + ignore = untracked + branch = master +[submodule "vendor/nim-protobuf-serialization"] + path = vendor/nim-protobuf-serialization + url = https://github.com/status-im/nim-protobuf-serialization.git + ignore = untracked + branch = master +[submodule "vendor/npeg"] + path = vendor/npeg + url = https://github.com/zevv/npeg.git + ignore = untracked + branch = master +[submodule "vendor/blake2"] + path = vendor/blake2 + url = https://github.com/narimiran/blake2.git + ignore = untracked + branch = master diff --git a/Makefile b/Makefile index 0a2539f..7446bde 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ export BUILD_SYSTEM_DIR := vendor/nimbus-build-system export EXCLUDED_NIM_PACKAGES := vendor/nwaku/vendor/nim-dnsdisc/vendor \ - vendor/nwaku/vendor/nimbus-build-system + vendor/nwaku/vendor/nimbus-build-system \ + vendor/nim-sds/vendor LINK_PCRE := 0 FORMAT_MSG := "\\x1B[95mFormatting:\\x1B[39m" # we don't want an error here, so we can handle things later, in the ".DEFAULT" target @@ -27,7 +28,7 @@ else # "variables.mk" was included. Business as usual until the end of this file .PHONY: all update clean # default target, because it's the first one that doesn't start with '.' -all: | waku_example +all: | waku_example nim_chat_poc test_file := $(word 2,$(MAKECMDGOALS)) define test_name @@ -81,6 +82,12 @@ waku_example: | build-waku-librln build-waku-nat nim_chat_poc.nims \ $(ENV_SCRIPT) nim waku_example $(NIM_PARAMS) nim_chat_poc.nims +nim_chat_poc: | build-waku-librln build-waku-nat nim_chat_poc.nims + echo -e $(BUILD_MSG) "build/$@" && \ + \ + $(ENV_SCRIPT) nim nim_chat_poc $(NIM_PARAMS) nim_chat_poc.nims + + endif diff --git a/src/nim_chat_poc.nim b/examples/nim_chat_poc.nim similarity index 94% rename from src/nim_chat_poc.nim rename to examples/nim_chat_poc.nim index fdb299b..1a486c7 100644 --- a/src/nim_chat_poc.nim +++ b/examples/nim_chat_poc.nim @@ -2,12 +2,12 @@ import chronos import chronicles import strformat -import chat_sdk/client -import chat_sdk/conversations -import chat_sdk/delivery/waku_client -import chat_sdk/utils +import ../src/chat_sdk/client +import ../src/chat_sdk/conversations +import ../src/chat_sdk/delivery/waku_client +import ../src/chat_sdk/utils -import content_types/all +import ../src/content_types/all const SELF_DEFINED = 99 diff --git a/namble.sh b/namble.sh new file mode 100755 index 0000000..a5c344d --- /dev/null +++ b/namble.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +# This script provides a 'nimble install' like interface for the nimbus build system. +# +# Usage: +# ./namble.sd +# +# +# The script +# - accesses https://nimble.directory/ +# - extracts the / from the project directory +# - invokes add_submodule. + +# Check if a pkg argument was provided +if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 +fi + + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ADD_SCRIPT="$SCRIPT_DIR/vendor/nimbus-build-system/scripts/add_submodule.sh" + +echo "$ADD_SCRIPT" + + +echo "Fetching nimble package $1" + +URL="https://nimble.directory/pkg/$1" + +auth_pkg=$(curl -s "$URL" \ + | grep -o '

" + exit 1 +fi + +echo Found "<$auth_pkg>" + +$ADD_SCRIPT $auth_pkg + +make update diff --git a/nim_chat_poc.nimble b/nim_chat_poc.nimble index 8c93d91..bfaf071 100644 --- a/nim_chat_poc.nimble +++ b/nim_chat_poc.nimble @@ -37,3 +37,7 @@ proc buildBinary(name: string, srcDir = "./", params = "", lang = "c") = task waku_example, "Build Waku based simple example": let name = "waku_example" buildBinary name, "examples/", " -d:chronicles_log_level='TRACE' " + +task nim_chat_poc, "Build Waku based simple example": + let name = "nim_chat_poc" + buildBinary name, "examples/", " -d:chronicles_log_level='TRACE' " diff --git a/vendor/blake2 b/vendor/blake2 new file mode 160000 index 0000000..625267e --- /dev/null +++ b/vendor/blake2 @@ -0,0 +1 @@ +Subproject commit 625267e5cb14c87e1d36d79ee24c2f4fe66edfdb diff --git a/vendor/nim-protobuf-serialization b/vendor/nim-protobuf-serialization new file mode 160000 index 0000000..4d74e15 --- /dev/null +++ b/vendor/nim-protobuf-serialization @@ -0,0 +1 @@ +Subproject commit 4d74e157cdf1bdcd0ffd41519ebde740c4b80447 diff --git a/vendor/nim-sds b/vendor/nim-sds new file mode 160000 index 0000000..6a05cfd --- /dev/null +++ b/vendor/nim-sds @@ -0,0 +1 @@ +Subproject commit 6a05cfd2c954886ebbe46adb222ecc1dc9117fd0 diff --git a/vendor/npeg b/vendor/npeg new file mode 160000 index 0000000..409f679 --- /dev/null +++ b/vendor/npeg @@ -0,0 +1 @@ +Subproject commit 409f6796d0e880b3f0222c964d1da7de6e450811