Skip to content

Commit faa6741

Browse files
fix: build zerokit rln from source via fixed nixpkgs, drop prebuilt fetch (#3930)
1 parent 3b03ca2 commit faa6741

3 files changed

Lines changed: 69 additions & 77 deletions

File tree

flake.lock

Lines changed: 49 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: 11 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,22 @@
1111
inputs = {
1212
# Pinning the commit to use same commit across different projects.
1313
# A commit from nixpkgs 25.11 release: https://github.com/NixOS/nixpkgs/tree/release-25.11
14-
nixpkgs.url = "github:NixOS/nixpkgs?rev=23d72dabcb3b12469f57b37170fcbc1789bd7457";
14+
# Includes the fetchCargoVendor crates.io CDN fix (nixpkgs 0fb82de3).
15+
nixpkgs.url = "github:NixOS/nixpkgs?rev=535f3e6942cb1cead3929c604320d3db54b542b9";
1516

1617
rust-overlay = {
1718
url = "github:oxalica/rust-overlay";
1819
inputs.nixpkgs.follows = "nixpkgs";
1920
};
21+
22+
# Zerokit v2.0.2; keep rev in sync with the vendor/zerokit submodule.
23+
zerokit = {
24+
url = "github:vacp2p/zerokit/5e64cb8822bee65eed6cf459f95ae72b80c6ba63";
25+
inputs.nixpkgs.follows = "nixpkgs";
26+
};
2027
};
2128

22-
outputs = { self, nixpkgs, rust-overlay }:
29+
outputs = { self, nixpkgs, rust-overlay, zerokit }:
2330
let
2431
systems = [
2532
"x86_64-linux" "aarch64-linux"
@@ -59,78 +66,12 @@
5966
inherit system;
6067
overlays = [ (import rust-overlay) nimbleOverlay ];
6168
};
62-
63-
# Prebuilt zerokit librln, fetched from the upstream GitHub release
64-
# rather than compiled from source. Compiling zerokit makes Nix download
65-
# its many crate dependencies from crates.io in one parallel burst, which
66-
# crates.io intermittently rejects with HTTP 403 (rate limiting from the
67-
# self-hosted runners' shared IP), breaking the nix build. The release
68-
# ships the exact `stateless` library this project links (see
69-
# scripts/build_rln.sh), so we use it directly — no Rust toolchain and
70-
# no crates.io access needed.
71-
#
72-
# Keep `rlnVersion` aligned with `LIBRLN_VERSION` in the Makefile and the
73-
# vendor/zerokit submodule. Each hash is the sha256 of the release tarball
74-
# for that platform; refresh all four when bumping the version.
75-
rlnVersion = "v2.0.2";
76-
rlnAssets = {
77-
"x86_64-linux" = { triple = "x86_64-unknown-linux-gnu"; hash = "sha256-qbrUdaetYKFhjzxUP/QcwD3JHWJ8qk/tCMK3yXceIAk="; };
78-
"aarch64-linux" = { triple = "aarch64-unknown-linux-gnu"; hash = "sha256-s4bWrmCcNTWHNyJwV73ilWNp58ZdAVG+TAgtWN1cTQs="; };
79-
"x86_64-darwin" = { triple = "x86_64-apple-darwin"; hash = "sha256-ZaHP5CApN66FYY7jxwOmGcF9kJR78Fng3k1qE2W08Mk="; };
80-
"aarch64-darwin" = { triple = "aarch64-apple-darwin"; hash = "sha256-f2YppkPsKFdN00j+IY8fpvsebWTIb9lW/V1/vOTiVKU="; };
81-
};
82-
83-
mkZerokitRln = system: pkgs:
84-
let
85-
asset = rlnAssets.${system} or
86-
(throw "zerokit ${rlnVersion} has no prebuilt rln asset for system '${system}'");
87-
in pkgs.stdenv.mkDerivation {
88-
pname = "librln";
89-
version = lib.removePrefix "v" rlnVersion;
90-
91-
src = pkgs.fetchurl {
92-
url = "https://github.com/vacp2p/zerokit/releases/download/"
93-
+ "${rlnVersion}/${asset.triple}-stateless-rln.tar.gz";
94-
hash = asset.hash;
95-
};
96-
97-
# The tarball lays its files out under release/.
98-
sourceRoot = "release";
99-
dontConfigure = true;
100-
dontBuild = true;
101-
102-
# The release .so was linked outside Nix, so it references system
103-
# libraries (libgcc_s, libstdc++, glibc) by bare name. autoPatchelfHook
104-
# points those at the Nix versions so the library loads correctly when
105-
# used by the Nix build. It does nothing for the static .a, and the
106-
# step is skipped on macOS (dylib paths are fixed in nix/default.nix).
107-
nativeBuildInputs =
108-
pkgs.lib.optionals pkgs.stdenv.isLinux [ pkgs.autoPatchelfHook ];
109-
buildInputs =
110-
pkgs.lib.optionals pkgs.stdenv.isLinux [ pkgs.stdenv.cc.cc.lib ];
111-
112-
installPhase = ''
113-
runHook preInstall
114-
mkdir -p $out/lib
115-
cp librln.a $out/lib/ 2>/dev/null || true
116-
cp librln.so $out/lib/ 2>/dev/null || true
117-
cp librln.dylib $out/lib/ 2>/dev/null || true
118-
runHook postInstall
119-
'';
120-
121-
meta = with pkgs.lib; {
122-
description = "Prebuilt zerokit RLN library (stateless flavor)";
123-
homepage = "https://github.com/vacp2p/zerokit";
124-
license = with licenses; [ mit asl20 ];
125-
platforms = builtins.attrNames rlnAssets;
126-
};
127-
};
12869
in {
12970
packages = forAllSystems (system:
13071
let
13172
pkgs = pkgsFor system;
13273

133-
zerokitRln = mkZerokitRln system pkgs;
74+
zerokitRln = import ./nix/zerokit.nix { inherit zerokit system; };
13475

13576
liblogosdelivery = pkgs.callPackage ./nix/default.nix {
13677
inherit pkgs;
@@ -147,9 +88,7 @@
14788
};
14889
in {
14990
inherit liblogosdelivery wakucanary;
150-
# Expose the prebuilt librln so downstream consumers
151-
# (e.g. logos-delivery-module) bundle the exact same librln this
152-
# build links against.
91+
# Expose librln so downstream consumers link the exact same build.
15392
rln = zerokitRln;
15493
default = liblogosdelivery;
15594
}

nix/zerokit.nix

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# zerokit rln built from source; overrides the stale v2.0.2 vendor cargoHash.
2+
{ zerokit, system }:
3+
zerokit.packages.${system}.rln.overrideAttrs (old: {
4+
cargoDeps = old.cargoDeps.overrideAttrs (oldCargoDeps: {
5+
vendorStaging = oldCargoDeps.vendorStaging.overrideAttrs (_: {
6+
outputHash = "sha256-PNwEdZLgGQPqQDrEK2hsQtSybVfBbD6xn4K47fPFJUU=";
7+
});
8+
});
9+
})

0 commit comments

Comments
 (0)