File tree Expand file tree Collapse file tree 9 files changed +190
-1
lines changed Expand file tree Collapse file tree 9 files changed +190
-1
lines changed Original file line number Diff line number Diff line change 4
4
- [ Guides] ( ./guides/index.md )
5
5
- [ Build Valence Contracts] ( ./guides/build-valence-contracts.md )
6
6
- [ Upload Contracts] ( ./guides/upload-contracts.md )
7
+ - [ ZK Development] ( ./guides/zk-development.md )
7
8
- [ Flake Modules Reference] ( ./reference/flake-modules/index.md )
8
9
- [ Upload Contracts Options] ( ./reference/flake-modules/upload-contracts.md )
9
10
- [ Valence Contracts Options] ( ./reference/flake-modules/valence-contracts.md )
Original file line number Diff line number Diff line change 1
1
# Guides
2
2
- [ Build Valence Contracts] ( ./build-valence-contracts.md )
3
3
- [ Upload Contracts] ( ./upload-contracts.md )
4
+ - [ ZK Development] ( ./zk-development.md )
4
5
Original file line number Diff line number Diff line change
1
+ # ZK Development
2
+
3
+ Zero.nix provides the ` sp1 ` and ` sp1-rust ` packages to make it
4
+ easy to setup a nix development shell with sp1 tooling.
5
+
6
+ To use them create a flake.nix with the following contents:
7
+ ``` nix
8
+ {{#include ../../templates/zk-development/flake.nix}}
9
+ ```
10
+ You can also run the following command to initialize the template.
11
+ ``` bash
12
+ nix flake init -t github:timewave-computer/zero.nix#zk-dev
13
+
14
+ ```
15
+
16
+ Then run ` nix develop ` to enter a devshell with the packages.
17
+
18
+
Original file line number Diff line number Diff line change 22
22
./packages/default.nix
23
23
./tools/default.nix
24
24
./docs/default.nix
25
+ ./templates/default.nix
25
26
./flakeModules/valence-contracts.nix
26
27
] ;
27
28
} ;
Original file line number Diff line number Diff line change 1
- { inputs , lib , ... } :
2
1
{
3
2
imports = [
4
3
./valence-contracts.nix
7
6
packages = {
8
7
upload-contract = pkgs . callPackage ./upload-contract { } ;
9
8
local-ic = pkgs . callPackage ./local-ic.nix { } ;
9
+ sp1-rust = pkgs . callPackage ./sp1-rust.nix { } ;
10
+ sp1 = pkgs . callPackage ./sp1.nix {
11
+ inherit ( config . packages ) sp1-rust ;
12
+ } ;
10
13
} ;
11
14
} ;
12
15
}
Original file line number Diff line number Diff line change
1
+ {
2
+ stdenv ,
3
+ autoPatchelfHook ,
4
+ fixDarwinDylibNames ,
5
+ fetchzip ,
6
+ zlib ,
7
+ ...
8
+ } :
9
+ let
10
+ fetchGitHubReleaseAsset =
11
+ {
12
+ owner ,
13
+ repo ,
14
+ tag ,
15
+ asset ,
16
+ hash ,
17
+ } :
18
+ fetchzip {
19
+ url = "https://github.com/${ owner } /${ repo } /releases/download/${ tag } /${ asset } " ;
20
+ inherit hash ;
21
+ stripRoot = false ;
22
+ } ;
23
+
24
+ in
25
+ stdenv . mkDerivation rec {
26
+ name = "sp1-rust" ;
27
+ version = "1.82.0" ;
28
+
29
+ nativeBuildInputs = [
30
+ stdenv . cc . cc . lib
31
+ zlib
32
+ ] ++ ( if stdenv . isDarwin then [ fixDarwinDylibNames ] else [ autoPatchelfHook ] ) ;
33
+
34
+ installPhase = ''
35
+ runHook preInstall
36
+ mkdir -p $out
37
+ cp -r ./* $out/
38
+ runHook postInstall
39
+ '' ;
40
+
41
+ src = fetchGitHubReleaseAsset ( {
42
+ owner = "succinctlabs" ;
43
+ repo = "rust" ;
44
+ tag = "succinct-${ version } " ;
45
+ } // {
46
+ "x86_64-linux" = {
47
+ asset = "rust-toolchain-x86_64-unknown-linux-gnu.tar.gz" ;
48
+ hash = "sha256-wXI2zVwfrVk28CR8PLq4xyepdlu65uamzt/+jER2M2k=" ;
49
+ } ;
50
+ "aarch64-linux" = {
51
+ asset = "rust-toolchain-aarch64-unknown-linux-gnu.tar.gz" ;
52
+ hash = "" ;
53
+ } ;
54
+ "x86_64-darwin" = {
55
+ asset = "rust-toolchain-x86_64-apple-darwin.tar.gz" ;
56
+ hash = "sha256-sPQW8eo+qItsmgK1uxRh1r73DBLUXUtmtVUvjacGzp0=" ;
57
+ } ;
58
+ "aarch64-darwin" = {
59
+ asset = "rust-toolchain-aarch64-apple-darwin.tar.gz" ;
60
+ hash = "sha256-R4D7hj2DcZ3vfCejvXwJ68YDOlgWGDPcb08GZNXz1Cg=" ;
61
+ } ;
62
+ } . ${ stdenv . system } ) ;
63
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ lib ,
3
+ sp1-rust ,
4
+ rustPlatform ,
5
+ fetchFromGitHub ,
6
+ pkg-config ,
7
+ openssl ,
8
+ ...
9
+ } :
10
+ rustPlatform . buildRustPackage {
11
+ pname = "sp1" ;
12
+ version = "unstable-2025-03-06" ;
13
+
14
+ nativeBuildInputs = [
15
+ sp1-rust
16
+ pkg-config
17
+ openssl
18
+ ] ;
19
+ cargoBuildFlags = [ "--package sp1-cli" ] ;
20
+ cargoHash = "sha256-gI/N381IfIWnF4tfXM1eKLI93eCjEELg/a5gWQn/3EA=" ;
21
+
22
+ src = fetchFromGitHub {
23
+ owner = "succinctlabs" ;
24
+ repo = "sp1" ;
25
+ rev = "9f202bf603b3cab5b7c9db0e8cf5524a3428fbee" ;
26
+ hash = "sha256-RpllsIlrGyYw6dInN0tTs7K1y4FiFmrxFSyt3/Xelkg=" ;
27
+ fetchSubmodules = true ;
28
+ } ;
29
+ doCheck = false ;
30
+ }
Original file line number Diff line number Diff line change
1
+ let
2
+ commonWelcome = ''
3
+ ## More info
4
+ - Zero.nix Docs: https://timewave.computer/zero.nix
5
+ '' ;
6
+ in
7
+ {
8
+ flake . templates = {
9
+ zk-dev = {
10
+ path = ./zk-development ;
11
+ description = "Simple ZK development environment" ;
12
+ welcomeText = ''
13
+ # Simple ZK development environment
14
+ ## Provided packages
15
+ - sp1 (cargo prove)
16
+ - rust-sp1
17
+
18
+ ${ commonWelcome }
19
+ '' ;
20
+ } ;
21
+ } ;
22
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ description = "Valence ZK development environment" ;
3
+
4
+ nixConfig . extra-experimental-features = "nix-command flakes" ;
5
+ nixConfig . extra-substituters = "https://timewave.cachix.org" ;
6
+ nixConfig . extra-trusted-public-keys = ''
7
+ colmena.cachix.org-1:7BzpDnjjH8ki2CT3f6GdOk7QAzPOl+1t3LvTLXqYcSg=
8
+ cosmos-nix.cachix.org-1:I9dmz4kn5+JExjPxOd9conCzQVHPl0Jo1Cdp6s+63d4=
9
+ nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=
10
+ '' ;
11
+
12
+
13
+ inputs = {
14
+ nixpkgs . url = "nixpkgs/nixos-24.11" ;
15
+
16
+ flake-parts . url = "github:hercules-ci/flake-parts" ;
17
+
18
+ devshell . url = "github:numtide/devshell" ;
19
+
20
+ zero-nix . url = "github:timewave-computer/zero.nix" ;
21
+ } ;
22
+
23
+ outputs = {
24
+ self ,
25
+ flake-parts ,
26
+ ...
27
+ } @ inputs :
28
+ flake-parts . lib . mkFlake { inherit inputs ; } {
29
+ imports = [
30
+ inputs . devshell . flakeModule
31
+ ] ;
32
+
33
+ systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ] ;
34
+
35
+ perSystem = {
36
+ pkgs ,
37
+ inputs ,
38
+ ...
39
+ } : {
40
+ devshells . workshop = { pkgs , ...} : {
41
+ commands = [
42
+ { package = pkgs . cargo ; }
43
+ { package = pkgs . rustc ; }
44
+ { package = inputs' . packages . sp1-rust ; }
45
+ { package = inputs' . packages . sp1 ; }
46
+ ] ;
47
+ } ;
48
+ } ;
49
+ } ;
50
+ }
You can’t perform that action at this time.
0 commit comments