Skip to content

Commit b899dd8

Browse files
committed
nix: add wakucanary Flake package
Signed-off-by: Jakub Sokołowski <[email protected]>
1 parent 797370e commit b899dd8

File tree

11 files changed

+81
-78
lines changed

11 files changed

+81
-78
lines changed

.github/workflows/nix-builds.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: ci / nix-builds
3+
on:
4+
pull_request:
5+
branches: [master]
6+
jobs:
7+
build:
8+
name: Build Nix Flake packages
9+
runs-on: [self-hosted, Linux]
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Build wakucanary
14+
shell: bash
15+
run: nix build '.?submodules=1#wakucanary'
16+
17+
- name: Build Android library
18+
shell: bash
19+
run: nix build '.?submodules=1#libwaku-android-arm64'

Makefile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,11 @@ nimbus-build-system-nimble-dir:
177177
.PHONY: librln
178178

179179
LIBRLN_BUILDDIR := $(CURDIR)/vendor/zerokit
180-
LIBRLN_VERSION := v0.7.0
180+
LIBRLN_VERSION ?= v0.7.0
181181

182+
LIBRLN_FILE ?= librln_$(LIBRLN_VERSION).a
182183
ifeq ($(detected_OS),Windows)
183-
LIBRLN_FILE := rln.lib
184-
else
185-
LIBRLN_FILE := librln_$(LIBRLN_VERSION).a
184+
LIBRLN_FILE ?= rln.lib
186185
endif
187186

188187
$(LIBRLN_FILE):
@@ -543,4 +542,3 @@ release-notes:
543542
sed -E 's@#([0-9]+)@[#\1](https://github.com/waku-org/nwaku/issues/\1)@g'
544543
# I could not get the tool to replace issue ids with links, so using sed for now,
545544
# asked here: https://github.com/bvieira/sv4git/discussions/101
546-

flake.lock

Lines changed: 27 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
inputs = {
1010
nixpkgs.url = "github:NixOS/nixpkgs?rev=f44bd8ca21e026135061a0a57dcf3d0775b67a49";
1111
zerokit = {
12-
url = "github:vacp2p/zerokit?rev=c60e0c33fc6350a4b1c20e6b6727c44317129582";
12+
# FIXME: This is patched v0.8.0, use v0.9.0 when ready.
13+
url = "github:vacp2p/zerokit?rev=8196edb206dda6d9a5d4a4eb9f660c95a4d25f57";
1314
inputs.nixpkgs.follows = "nixpkgs";
1415
};
1516
};
@@ -49,16 +50,23 @@
4950
libwaku-android-arm64 = pkgs.callPackage ./nix/default.nix {
5051
inherit stableSystems;
5152
src = self;
52-
targets = ["libwaku-android-arm64"];
53-
androidArch = "aarch64-linux-android";
53+
targets = ["libwaku-android-arm64"];
5454
abidir = "arm64-v8a";
55-
zerokitPkg = zerokit.packages.${system}.zerokit-android-arm64;
55+
zerokitRln = zerokit.packages.${system}.rln-android-arm64;
5656
};
57+
58+
wakucanary = pkgs.callPackage ./nix/default.nix {
59+
inherit stableSystems;
60+
src = self;
61+
targets = ["wakucanary"];
62+
zerokitRln = zerokit.packages.${system}.rln;
63+
};
64+
5765
default = libwaku-android-arm64;
5866
});
5967

6068
devShells = forAllSystems (system: {
6169
default = pkgsFor.${system}.callPackage ./nix/shell.nix {};
6270
});
6371
};
64-
}
72+
}

nix/atlas.nix

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

nix/checksums.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ let
66
in pkgs.fetchFromGitHub {
77
owner = "nim-lang";
88
repo = "checksums";
9-
rev = tools.findKeyValue "^ +ChecksumsStableCommit = \"([a-f0-9]+)\"$" sourceFile;
9+
rev = tools.findKeyValue "^ +ChecksumsStableCommit = \"([a-f0-9]+)\".*$" sourceFile;
1010
# WARNING: Requires manual updates when Nim compiler version changes.
11-
hash = "sha256-Bm5iJoT2kAvcTexiLMFBa9oU5gf7d4rWjo3OiN7obWQ=";
11+
hash = "sha256-JZhWqn4SrAgNw/HLzBK0rrj3WzvJ3Tv1nuDMn83KoYY=";
1212
}

nix/csources.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ in pkgs.fetchFromGitHub {
99
rev = tools.findKeyValue "^nim_csourcesHash=([a-f0-9]+)$" sourceFile;
1010
# WARNING: Requires manual updates when Nim compiler version changes.
1111
hash = "sha256-UCLtoxOcGYjBdvHx7A47x6FjLMi6VZqpSs65MN7fpBs=";
12-
}
12+
}

nix/default.nix

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
stableSystems ? [
1010
"x86_64-linux" "aarch64-linux"
1111
],
12-
androidArch,
13-
abidir,
14-
zerokitPkg,
12+
abidir ? null,
13+
zerokitRln,
1514
}:
1615

1716
assert pkgs.lib.assertMsg ((src.submodules or true) == true)
@@ -20,15 +19,11 @@ assert pkgs.lib.assertMsg ((src.submodules or true) == true)
2019
let
2120
inherit (pkgs) stdenv lib writeScriptBin callPackage;
2221

23-
revision = lib.substring 0 8 (src.rev or "dirty");
22+
version = lib.substring 0 8 (src.sourceInfo.rev or "dirty");
2423

2524
in stdenv.mkDerivation rec {
26-
2725
pname = "nwaku";
28-
29-
version = "1.0.0-${revision}";
30-
31-
inherit src;
26+
inherit src version;
3227

3328
buildInputs = with pkgs; [
3429
openssl
@@ -40,30 +35,22 @@ in stdenv.mkDerivation rec {
4035
nativeBuildInputs = let
4136
# Fix for Nim compiler calling 'git rev-parse' and 'lsb_release'.
4237
fakeGit = writeScriptBin "git" "echo ${version}";
43-
# Fix for the zerokit package that is built with cargo/rustup/cross.
44-
fakeCargo = writeScriptBin "cargo" "echo ${version}";
45-
# Fix for the zerokit package that is built with cargo/rustup/cross.
46-
fakeRustup = writeScriptBin "rustup" "echo ${version}";
47-
# Fix for the zerokit package that is built with cargo/rustup/cross.
48-
fakeCross = writeScriptBin "cross" "echo ${version}";
4938
in
5039
with pkgs; [
5140
cmake
5241
which
5342
lsb-release
54-
zerokitPkg
55-
nim-unwrapped-2_0
43+
zerokitRln
44+
nim-unwrapped-2_2
5645
fakeGit
57-
fakeCargo
58-
fakeRustup
59-
fakeCross
6046
];
6147

6248
# Environment variables required for Android builds
6349
ANDROID_SDK_ROOT="${pkgs.androidPkgs.sdk}";
6450
ANDROID_NDK_HOME="${pkgs.androidPkgs.ndk}";
6551
NIMFLAGS = "-d:disableMarchNative -d:git_revision_override=${revision}";
6652
XDG_CACHE_HOME = "/tmp";
53+
LIBRLN_FILE = "${zerokitRln}/lib/librln.a";
6754
androidManifest = "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" package=\"com.example.mylibrary\" />";
6855

6956
makeFlags = targets ++ [
@@ -84,27 +71,20 @@ in stdenv.mkDerivation rec {
8471
pushd vendor/nimbus-build-system/vendor/Nim
8572
mkdir dist
8673
cp -r ${callPackage ./nimble.nix {}} dist/nimble
87-
chmod 777 -R dist/nimble
88-
mkdir -p dist/nimble/dist
89-
cp -r ${callPackage ./checksums.nix {}} dist/checksums # need both
90-
cp -r ${callPackage ./checksums.nix {}} dist/nimble/dist/checksums
91-
cp -r ${callPackage ./atlas.nix {}} dist/atlas
92-
chmod 777 -R dist/atlas
93-
mkdir dist/atlas/dist
94-
cp -r ${callPackage ./sat.nix {}} dist/nimble/dist/sat
95-
cp -r ${callPackage ./sat.nix {}} dist/atlas/dist/sat
74+
cp -r ${callPackage ./checksums.nix {}} dist/checksums
9675
cp -r ${callPackage ./csources.nix {}} csources_v2
9776
chmod 777 -R dist/nimble csources_v2
9877
popd
99-
mkdir -p vendor/zerokit/target/${androidArch}/release
100-
cp ${zerokitPkg}/librln.so vendor/zerokit/target/${androidArch}/release/
10178
'';
10279

103-
installPhase = ''
80+
installPhase = if abidir != null then ''
10481
mkdir -p $out/jni
10582
cp -r ./build/android/${abidir}/* $out/jni/
10683
echo '${androidManifest}' > $out/jni/AndroidManifest.xml
10784
cd $out && zip -r libwaku.aar *
85+
'' else ''
86+
mkdir -p $out/bin
87+
cp -r build/* $out/bin
10888
'';
10989

11090
meta = with pkgs.lib; {

nix/nimble.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ let
66
in pkgs.fetchFromGitHub {
77
owner = "nim-lang";
88
repo = "nimble";
9-
rev = tools.findKeyValue "^ +NimbleStableCommit = \"([a-f0-9]+)\".+" sourceFile;
9+
rev = tools.findKeyValue "^ +NimbleStableCommit = \"([a-f0-9]+)\".*$" sourceFile;
1010
# WARNING: Requires manual updates when Nim compiler version changes.
11-
hash = "sha256-MVHf19UbOWk8Zba2scj06PxdYYOJA6OXrVyDQ9Ku6Us=";
12-
}
11+
hash = "sha256-8iutVgNzDtttZ7V+7S11KfLEuwhKA9TsgS51mlUI08k=";
12+
}

nix/sat.nix

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

0 commit comments

Comments
 (0)