forked from matter-labs/zksync-era
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
142 lines (123 loc) · 4.23 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
###################################################################################################
#
# see `README.md` in `etc/nix`
#
###################################################################################################
{
description = "ZKsync-era";
nixConfig = {
extra-substituters = [ "https://attic.teepot.org/tee-pot" ];
extra-trusted-public-keys = [ "tee-pot:SS6HcrpG87S1M6HZGPsfo7d1xJccCGev7/tXc5+I4jg=" ];
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
teepot-flake.url = "github:matter-labs/teepot";
nixsgx-flake.url = "github:matter-labs/nixsgx";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
crane = {
url = "github:ipetkov/crane?tag=v0.17.3";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, teepot-flake, nixsgx-flake, flake-utils, rust-overlay, crane }:
let
officialRelease = false;
hardeningEnable = [ "fortify3" "pie" "relro" ];
out = system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
rust-overlay.overlays.default
nixsgx-flake.overlays.default
teepot-flake.overlays.default
];
};
appliedOverlay = self.overlays.default pkgs pkgs;
in
{
formatter = pkgs.nixpkgs-fmt;
packages = {
# to ease potential cross-compilation, the overlay is used
inherit (appliedOverlay.zksync-era) zksync tee_prover container-tee-prover-azure container-tee-prover-dcap;
default = appliedOverlay.zksync-era.tee_prover;
};
devShells.default = appliedOverlay.zksync-era.devShell;
};
in
flake-utils.lib.eachDefaultSystem out // {
overlays.default = final: prev:
# to ease potential cross-compilation, the overlay is used
let
pkgs = final;
rustVersion = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain;
rustPlatform = pkgs.makeRustPlatform {
cargo = rustVersion;
rustc = rustVersion;
};
craneLib = (crane.mkLib pkgs).overrideToolchain rustVersion;
commonArgs = {
nativeBuildInputs = with pkgs;[
pkg-config
rustPlatform.bindgenHook
];
buildInputs = with pkgs;[
libclang.dev
openssl.dev
snappy.dev
lz4.dev
bzip2.dev
rocksdb
snappy.dev
];
src = with pkgs.lib.fileset; toSource {
root = ./.;
fileset = unions [
./Cargo.lock
./Cargo.toml
./core
./prover
./zkstack_cli
./.github/release-please/manifest.json
];
};
env = {
OPENSSL_NO_VENDOR = "1";
ROCKSDB_LIB_DIR = "${pkgs.rocksdb.out}/lib";
SNAPPY_LIB_DIR = "${pkgs.snappy.out}/lib";
NIX_OUTPATH_USED_AS_RANDOM_SEED = "aaaaaaaaaa";
};
doCheck = false;
strictDeps = true;
inherit hardeningEnable;
};
in
{
zksync-era = rec {
devShell = pkgs.callPackage ./etc/nix/devshell.nix {
inherit zksync;
inherit commonArgs;
};
zksync = pkgs.callPackage ./etc/nix/zksync.nix {
inherit craneLib;
inherit commonArgs;
};
tee_prover = pkgs.callPackage ./etc/nix/tee_prover.nix {
inherit craneLib;
inherit commonArgs;
};
container-tee-prover-azure = pkgs.callPackage ./etc/nix/container-tee_prover.nix {
inherit tee_prover;
isAzure = true;
container-name = "zksync-tee-prover-azure";
};
container-tee-prover-dcap = pkgs.callPackage ./etc/nix/container-tee_prover.nix {
inherit tee_prover;
isAzure = false;
container-name = "zksync-tee-prover-dcap";
};
};
};
};
}