|
11 | 11 | inputs = { |
12 | 12 | # Pinning the commit to use same commit across different projects. |
13 | 13 | # 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"; |
15 | 16 |
|
16 | 17 | rust-overlay = { |
17 | 18 | url = "github:oxalica/rust-overlay"; |
18 | 19 | inputs.nixpkgs.follows = "nixpkgs"; |
19 | 20 | }; |
| 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 | + }; |
20 | 27 | }; |
21 | 28 |
|
22 | | - outputs = { self, nixpkgs, rust-overlay }: |
| 29 | + outputs = { self, nixpkgs, rust-overlay, zerokit }: |
23 | 30 | let |
24 | 31 | systems = [ |
25 | 32 | "x86_64-linux" "aarch64-linux" |
|
59 | 66 | inherit system; |
60 | 67 | overlays = [ (import rust-overlay) nimbleOverlay ]; |
61 | 68 | }; |
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 | | - }; |
128 | 69 | in { |
129 | 70 | packages = forAllSystems (system: |
130 | 71 | let |
131 | 72 | pkgs = pkgsFor system; |
132 | 73 |
|
133 | | - zerokitRln = mkZerokitRln system pkgs; |
| 74 | + zerokitRln = import ./nix/zerokit.nix { inherit zerokit system; }; |
134 | 75 |
|
135 | 76 | liblogosdelivery = pkgs.callPackage ./nix/default.nix { |
136 | 77 | inherit pkgs; |
|
147 | 88 | }; |
148 | 89 | in { |
149 | 90 | 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. |
153 | 92 | rln = zerokitRln; |
154 | 93 | default = liblogosdelivery; |
155 | 94 | } |
|
0 commit comments