progress towards using nix and nimble properly

This commit is contained in:
Ivan Folgueira Bande 2026-02-13 12:20:16 +01:00
parent ea9a525fbe
commit 827d44564e
No known key found for this signature in database
GPG Key ID: 3C117481F89E24A7
8 changed files with 46 additions and 132 deletions

View File

@ -64,13 +64,13 @@ waku.nims:
update: | waku.nims
git submodule update --init --recursive
nimble setup -y
nimble setup --localdeps
nimble install --depsOnly
$(MAKE) build-nph
clean:
rm -rf build
rm -rf ~/.nimble/pkgs2
rm -rf ~/.nimble/pkgcache
rm -rf nimbledeps
build:
mkdir -p build
@ -137,10 +137,6 @@ endif
rln-deps: rustup
./scripts/install_rln_tests_dependencies.sh $(FOUNDRY_VERSION) $(PNPM_VERSION)
# Install nimble dependencies
deps: | build waku.nims
nimble install -d -y
##################
## RLN ##
##################
@ -157,7 +153,7 @@ endif
$(LIBRLN_FILE):
echo -e $(BUILD_MSG) "$@" && \
./scripts/build_rln.sh $(LIBRLN_BUILDDIR) $(LIBRLN_VERSION) $(LIBRLN_FILE)
bash scripts/build_rln.sh $(LIBRLN_BUILDDIR) $(LIBRLN_VERSION) $(LIBRLN_FILE)
librln: | $(LIBRLN_FILE)
$(eval NIM_PARAMS += --passL:$(LIBRLN_FILE) --passL:-lm)
@ -173,7 +169,7 @@ clean: | clean-librln
#################
.PHONY: testcommon
testcommon: | build deps
testcommon: | build
echo -e $(BUILD_MSG) "build/$@" && \
nimble testcommon
@ -182,59 +178,59 @@ testcommon: | build deps
##########
.PHONY: testwaku wakunode2 testwakunode2 example2 chat2 chat2bridge liteprotocoltester
testwaku: | build deps rln-deps librln
testwaku: | build rln-deps librln
echo -e $(BUILD_MSG) "build/$@" && \
nimble test
wakunode2: | build deps librln
wakunode2: | build librln
echo -e $(BUILD_MSG) "build/$@" && \
nimble wakunode2
benchmarks: | build deps librln
benchmarks: | build librln
echo -e $(BUILD_MSG) "build/$@" && \
nimble benchmarks
testwakunode2: | build deps librln
testwakunode2: | build librln
echo -e $(BUILD_MSG) "build/$@" && \
nimble testwakunode2
example2: | build deps librln
example2: | build librln
echo -e $(BUILD_MSG) "build/$@" && \
nimble example2
chat2: | build deps librln
chat2: | build librln
echo -e $(BUILD_MSG) "build/$@" && \
nimble chat2
chat2mix: | build deps librln
chat2mix: | build librln
echo -e $(BUILD_MSG) "build/$@" && \
nimble chat2mix
rln-db-inspector: | build deps librln
rln-db-inspector: | build librln
echo -e $(BUILD_MSG) "build/$@" && \
nimble rln_db_inspector
chat2bridge: | build deps librln
chat2bridge: | build librln
echo -e $(BUILD_MSG) "build/$@" && \
nimble chat2bridge
liteprotocoltester: | build deps librln
liteprotocoltester: | build librln
echo -e $(BUILD_MSG) "build/$@" && \
nimble liteprotocoltester
lightpushwithmix: | build deps librln
lightpushwithmix: | build librln
echo -e $(BUILD_MSG) "build/$@" && \
nimble lightpushwithmix
api_example: | build deps librln
api_example: | build librln
echo -e $(BUILD_MSG) "build/$@" && \
$(ENV_SCRIPT) nim api_example $(NIM_PARAMS) waku.nims
build/%: | build deps librln
build/%: | build librln
echo -e $(BUILD_MSG) "build/$*" && \
nimble buildone $*
compile-test: | build deps librln
compile-test: | build librln
echo -e $(BUILD_MSG) "$(TEST_FILE)" "\"$(TEST_NAME)\"" && \
nimble buildTest $(TEST_FILE) && \
nimble execTest $(TEST_FILE) "\"$(TEST_NAME)\""
@ -246,11 +242,11 @@ compile-test: | build deps librln
tools: networkmonitor wakucanary
wakucanary: | build deps librln
wakucanary: | build librln
echo -e $(BUILD_MSG) "build/$@" && \
nimble wakucanary
networkmonitor: | build deps librln
networkmonitor: | build librln
echo -e $(BUILD_MSG) "build/$@" && \
nimble networkmonitor
@ -326,7 +322,7 @@ docker-quick-image: MAKE_TARGET ?= wakunode2
docker-quick-image: DOCKER_IMAGE_TAG ?= $(MAKE_TARGET)-$(GIT_VERSION)
docker-quick-image: DOCKER_IMAGE_NAME ?= wakuorg/nwaku:$(DOCKER_IMAGE_TAG)
docker-quick-image: NIM_PARAMS := $(NIM_PARAMS) -d:chronicles_colors:none -d:insecure -d:postgres --passL:$(LIBRLN_FILE) --passL:-lm
docker-quick-image: | build deps librln wakunode2
docker-quick-image: | build librln wakunode2
docker build \
--build-arg="MAKE_TARGET=$(MAKE_TARGET)" \
--tag $(DOCKER_IMAGE_NAME) \
@ -395,7 +391,7 @@ ifeq ($(STATIC), 1)
endif
libwaku: | build librln
nimble --verbose $(BUILD_COMMAND) waku.nimble
nimble --verbose $(BUILD_COMMAND) waku.nimble $@.$(LIB_EXT)
cwaku_example: | build libwaku
echo -e $(BUILD_MSG) "build/$@" && \

View File

@ -1,5 +1,9 @@
import os
--noNimblePath
when withDir(thisDir(), system.fileExists("nimble.paths")):
include "nimble.paths"
if defined(windows):
switch("passL", "rln.lib")
switch("define", "postgres=false")

View File

@ -170,7 +170,7 @@
},
"chronos": {
"version": "4.0.4",
"vcsRevision": "0d00279e67ad9fadeb944944449adc89f052b8bd",
"vcsRevision": "0646c444fce7c7ed08ef6f2c9a7abfd172ffe655",
"url": "https://github.com/status-im/nim-chronos",
"downloadMethod": "git",
"dependencies": [
@ -182,7 +182,7 @@
"unittest2"
],
"checksums": {
"sha1": "add14e711abc98b2203e7c5a35c860c7b86f15b5"
"sha1": "455802a90204d8ad6b31d53f2efff8ebfe4c834a"
}
},
"metrics": {

View File

@ -3,8 +3,6 @@
src ? ../.,
targets ? ["libwaku-android-arm64"],
verbosity ? 1,
useSystemNim ? true,
quickAndDirty ? true,
stableSystems ? [
"x86_64-linux" "aarch64-linux"
],
@ -25,12 +23,8 @@ let
copyWakunode2 = lib.elem "wakunode2" targets;
hasKnownInstallTarget = copyLibwaku || copyLiblogosdelivery || copyWakunode2;
nimPinned = pkgs.callPackage ./nim.nix {};
nimblePinned = pkgs.callPackage ./nimble.nix { inherit nimPinned; };
nimbleDeps = callPackage ./deps.nix {
inherit src version revision;
mynimble = nimblePinned;
};
in stdenv.mkDerivation {
@ -45,7 +39,7 @@ in stdenv.mkDerivation {
};
buildInputs = with pkgs; [
openssl gmp zip nimble
openssl gmp zip bash nim nimble cacert
];
# Dependencies that should only exist in the build environment.
@ -53,16 +47,13 @@ in stdenv.mkDerivation {
# Fix for Nim compiler calling 'git rev-parse' and 'lsb_release'.
fakeGit = writeScriptBin "git" "echo ${version}";
in with pkgs; [
cmake which zerokitRln fakeGit nimbleDeps cargo
cmake which zerokitRln fakeGit nimbleDeps cargo nimble nim cacert
] ++ lib.optionals stdenv.isDarwin [
pkgs.darwin.cctools gcc # Necessary for libbacktrace
];
makeFlags = targets ++ [
"V=${toString verbosity}"
"QUICK_AND_DIRTY_COMPILER=${if quickAndDirty then "1" else "0"}"
"QUICK_AND_DIRTY_NIMBLE=${if quickAndDirty then "1" else "0"}"
"USE_SYSTEM_NIM=${if useSystemNim then "1" else "0"}"
"LIBRLN_FILE=${zerokitRln}/lib/librln.${if abidir != null then "so" else "a"}"
"POSTGRES=1"
];
@ -70,10 +61,6 @@ in stdenv.mkDerivation {
configurePhase = ''
export HOME=$TMPDIR
export XDG_CACHE_HOME=$TMPDIR
export NIMBLE_DIR=$TMPDIR/nimbledir
mkdir -p $NIMBLE_DIR/pkgs2/nim-2.2.6/bin
cp -r ${nimPinned}/bin/* $NIMBLE_DIR/pkgs2/nim-2.2.6/bin/
cp -r ${nimbleDeps}/nimbledeps $NIMBLE_DIR
cp ${nimbleDeps}/nimble.paths ./
@ -83,6 +70,10 @@ in stdenv.mkDerivation {
'';
buildPhase = ''
nimble --verbose --offline libwakuDynamic --noRefresh --noNimblePath waku.nimble libwaku.so
'';
installPhase = if abidir != null then ''
mkdir -p $out/jni
cp -r ./build/android/${abidir}/* $out/jni/

View File

@ -3,7 +3,7 @@
, src
, version
, revision
, mynimble }:
}:
stdenv.mkDerivation {
pname = "logos-delivery-nimble-deps";
@ -13,7 +13,7 @@ stdenv.mkDerivation {
nativeBuildInputs = with pkgs; [
jq rsync git cacert moreutils
] ++ [ mynimble ];
] ++ [ nimble ];
configurePhase = ''
export XDG_CACHE_HOME=$TMPDIR
@ -23,8 +23,8 @@ stdenv.mkDerivation {
buildPhase = ''
nimble --version
nimble --silent --localdeps setup
nimble --silent --localdeps install -y --depsOnly
nimble --localdeps setup
nimble --localdeps install
'';
installPhase = ''
@ -38,6 +38,10 @@ stdenv.mkDerivation {
--include='*.json' \
--include='*.nim' \
--include='*.nimble' \
--include='*.c' \
--include='*.h' \
--include='*.S' \
--include='*.cc' \
--exclude='*' \
$NIMBLE_DIR/pkgs2 $out/nimbledeps
'';
@ -54,7 +58,7 @@ stdenv.mkDerivation {
'';
# Make this a fixed-output derivation to allow internet access for Nimble.
outputHash = "sha256-hW01MZL8cb4Iby6HTomYWCP+LkY6PK1o+qaOeWYsWuE=";
outputHash = "sha256-5NZ0RPK8ssxNdyuBbFNljct5hjnIM1FrHzWwL8ujuqY=";
outputHashAlgo = "sha256";
outputHashMode = "recursive";
}

View File

@ -1,33 +0,0 @@
{ lib
, stdenv
, fetchurl
, pkgconfig
, gcc }:
stdenv.mkDerivation rec {
pname = "nim";
version = "2.2.6";
src = fetchurl {
url = "https://github.com/nim-lang/Nim/archive/refs/tags/v2.2.6.tar.gz";
sha256 = "0q27fxky7xh0r5kyldl02dm5rs5pkz96g2sgfgwpxy4v86b6qlpp"; # computed via nix-prefetch-url
};
nativeBuildInputs = [ gcc pkgconfig ];
buildPhase = ''
cd $src
sh build.sh
'';
installPhase = ''
mkdir -p $out/bin
cp bin/nim $out/bin/
'';
meta = with lib; {
description = "Official Nim compiler 2.2.6";
homepage = "https://nim-lang.org";
license = lib.licenses.mit;
};
}

View File

@ -1,48 +0,0 @@
{ lib
, stdenv
, fetchgit
, pkg-config
, pkgs
, nimPinned
}:
stdenv.mkDerivation rec {
pname = "my-nimble";
version = "0.99.0-9e488db"; # your own human version
src = fetchgit {
url = "https://github.com/nim-lang/nimble.git";
rev = "9e488db1233004d6fb42923739f8b8cb12485f30";
# computed hash of the Git snapshot:
sha256 = "sha256-MhLkXgnwsCtbPbxo3J3e+//6BMsTEgvDZlbPY/ONEeE=";
};
nativeBuildInputs = [ pkg-config nim pkgs.openssl ];
configurePhase = ''
export HOME=$TMPDIR
mkdir -p $NIMBLE_DIR/pkgs2/nim-2.2.6/bin
cp -r ${nimPinned}/bin/* $NIMBLE_DIR/pkgs2/nim-2.2.6/bin/
'';
buildPhase = ''
echo "Copying source to build directory..."
cp -r $src/* . # Copy into $PWD
echo "Compiling nimble..."
nim c -d:release src/nimble.nim
'';
installPhase = ''
mkdir -p $out/bin
cp src/nimble $out/bin/
'';
meta = with lib; {
description = "Nim package manager from specific commit";
homepage = "https://github.com/nim-lang/nimble";
license = licenses.mit;
maintainers = [];
};
}

View File

@ -8,10 +8,10 @@ version = "0.36.0"
author = "Status Research & Development GmbH"
description = "Waku, Private P2P Messaging for Resource-Restricted Devices"
license = "MIT or Apache License 2.0"
#bin = @["build/waku"]
srcDir = "waku"
### Dependencies
requires "nim >= 2.2.6",
requires "nim >= 2.2.4",
# Async & Concurrency
"chronos >= 4.0.4",
"taskpools",