Skip to content

Commit e98a303

Browse files
monyarmPetarKirov
authored andcommitted
feat(rapidsnark-gpu): Add rapidsnark-gpu package
1 parent b58b18f commit e98a303

File tree

3 files changed

+80
-13
lines changed

3 files changed

+80
-13
lines changed

flake.nix

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@
3131
};
3232

3333
outputs =
34-
inputs@{ flake-parts, nixos-modules, ... }:
34+
inputs@{
35+
flake-parts,
36+
nixos-modules,
37+
nixpkgs,
38+
...
39+
}:
3540
flake-parts.lib.mkFlake { inherit inputs; } {
3641
systems = [
3742
"x86_64-linux"
@@ -45,26 +50,29 @@
4550
];
4651
perSystem =
4752
{
48-
final,
4953
self',
5054
config,
55+
system,
56+
pkgs,
5157
...
5258
}:
5359
{
60+
_module.args.pkgs = import nixpkgs {
61+
inherit system;
62+
config.allowUnfree = true;
63+
};
5464
devShells.default = import ./shells/all.nix {
55-
pkgs = final;
56-
inherit self';
65+
inherit pkgs self';
5766
};
5867
devShells.ci = import ./shells/ci.nix {
59-
pkgs = final;
60-
inherit config;
68+
inherit pkgs config;
6169
};
62-
devShells.nexus = import ./shells/nexus.nix { pkgs = final; };
63-
devShells.jolt = import ./shells/jolt.nix { pkgs = final; };
64-
devShells.zkm = import ./shells/zkm.nix { pkgs = final; };
65-
devShells.zkwasm = import ./shells/zkwasm.nix { pkgs = final; };
66-
devShells.sp1 = import ./shells/sp1.nix { pkgs = final; };
67-
devShells.risc0 = import ./shells/risc0.nix { pkgs = final; };
70+
devShells.nexus = import ./shells/nexus.nix { inherit pkgs config; };
71+
devShells.jolt = import ./shells/jolt.nix { inherit pkgs config; };
72+
devShells.zkm = import ./shells/zkm.nix { inherit pkgs config; };
73+
devShells.zkwasm = import ./shells/zkwasm.nix { inherit pkgs config; };
74+
devShells.sp1 = import ./shells/sp1.nix { inherit pkgs config; };
75+
devShells.risc0 = import ./shells/risc0.nix { inherit pkgs config; };
6876
};
6977
};
7078
}

packages/all-packages.nix

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@
6868
rapidsnark = callPackage ./rapidsnark/default.nix {
6969
inherit ffiasm zqfield-bn254;
7070
};
71+
rapidsnark-gpu = callPackage ./rapidsnark-gpu/default.nix {
72+
inherit ffiasm zqfield-bn254;
73+
};
7174

7275
# Elrond / MultiversX
7376
# copied from https://github.com/NixOS/nixpkgs/blob/8df7949791250b580220eb266e72e77211bedad9/pkgs/development/python-modules/cryptography/default.nix
@@ -229,7 +232,7 @@
229232
}
230233
// lib.optionalAttrs (hostPlatform.isx86 && hostPlatform.isLinux) rec {
231234
pistache = callPackage ./pistache/default.nix { };
232-
inherit zqfield-bn254;
235+
inherit zqfield-bn254 rapidsnark-gpu;
233236
rapidsnark-server = callPackage ./rapidsnark-server/default.nix {
234237
inherit
235238
ffiasm
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
lib,
3+
cudaPackages,
4+
stdenv,
5+
ffiasm,
6+
zqfield-bn254,
7+
nlohmann_json,
8+
gmp,
9+
libsodium,
10+
cmake,
11+
fetchFromGitHub,
12+
pkg-config,
13+
}:
14+
let
15+
ffiasm-c = "${ffiasm}/lib/node_modules/ffiasm/c";
16+
in
17+
stdenv.mkDerivation rec {
18+
pname = "rapidsnark-gpu";
19+
version = "2023-04-08";
20+
21+
src = fetchFromGitHub {
22+
owner = "Orbiter-Finance";
23+
repo = "rapidsnark";
24+
rev = "77016322808ac58a3acd25a6235510b55172f967";
25+
hash = "sha256-8vy+iXkSINFregve+rej1rXyXdWxm0n1wvYfoy/0idk=";
26+
};
27+
28+
nativeBuildInputs = [ pkg-config ];
29+
buildInputs = [
30+
nlohmann_json
31+
gmp
32+
libsodium
33+
cudaPackages.cudatoolkit
34+
] ++ ffiasm.passthru.openmp;
35+
36+
buildPhase = ''
37+
mkdir -p $out/bin
38+
c++ \
39+
-I{${ffiasm-c},${zqfield-bn254}/lib} \
40+
./src/{main_prover,binfile_utils,zkey_utils,wtns_utils,logger}.cpp \
41+
${ffiasm-c}/{alt_bn128,misc,naf,splitparstr}.cpp \
42+
${zqfield-bn254}/lib/{fq,fr}.{cpp,o} \
43+
$(pkg-config --cflags --libs libsodium gmp nlohmann_json) \
44+
-std=c++17 -pthread -O3 -fopenmp \
45+
-o $out/bin/prover
46+
'';
47+
48+
installPhase = ''
49+
# Already done in buildPhase
50+
'';
51+
52+
meta = {
53+
homepage = "https://github.com/iden3/rapidsnark";
54+
platforms = with lib.platforms; linux ++ darwin;
55+
};
56+
}

0 commit comments

Comments
 (0)