-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
Copy pathflake.nix
140 lines (123 loc) · 4.81 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
###################################################################################################
#
# 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.11";
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.20.0";
};
outputs = { self, nixpkgs, teepot-flake, nixsgx-flake, flake-utils, rust-overlay, crane } @ inputs:
let
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 zkstack foundry-zksync;
default = appliedOverlay.zksync-era.tee_prover;
} // (pkgs.lib.optionalAttrs (pkgs.stdenv.hostPlatform.isx86_64 && pkgs.stdenv.hostPlatform.isLinux) {
inherit (appliedOverlay.zksync-era) container-tee-prover-azure container-tee-prover-dcap container-tee-prover-tdx;
});
devShells = {
inherit (appliedOverlay.zksync-era) devShell devShellAll;
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;
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain;
rustPlatform = pkgs.makeRustPlatform {
cargo = toolchain;
rustc = toolchain;
};
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
coreCommonArgs = {
nativeBuildInputs = with pkgs;[
pkg-config
rustPlatform.bindgenHook
];
buildInputs = with pkgs;[
libclang.dev
openssl.dev
snappy.dev
lz4.dev
bzip2.dev
rocksdb_8_3
snappy.dev
];
src = with pkgs.lib.fileset; let root = ./core/.; in toSource {
inherit root;
fileset = unions [
# Default files from crane (Rust and cargo files)
(craneLib.fileset.commonCargoSources root)
# proto files and friends
(fileFilter (file: file.hasExt "proto" || file.hasExt "js" || file.hasExt "ts" || file.hasExt "map" || file.hasExt "json") root)
(maybeMissing ./core/lib/dal/.)
];
};
env = {
OPENSSL_NO_VENDOR = "1";
ROCKSDB_LIB_DIR = "${pkgs.rocksdb_8_3.out}/lib";
ROCKSDB_INCLUDE_DIR = "${pkgs.rocksdb_8_3.out}/include";
SNAPPY_LIB_DIR = "${pkgs.snappy.out}/lib";
NIX_OUTPATH_USED_AS_RANDOM_SEED = "aaaaaaaaaa";
};
doCheck = false;
strictDeps = true;
inherit hardeningEnable;
};
zkstackArgs = coreCommonArgs // {
src = with pkgs.lib.fileset; let root = ./.; in toSource {
inherit root;
fileset = unions [
# Default files from crane (Rust and cargo files)
(craneLib.fileset.commonCargoSources root)
# proto files and friends
(fileFilter (file: file.hasExt "proto" || file.hasExt "js" || file.hasExt "ts" || file.hasExt "map" || file.hasExt "json") ./.)
(maybeMissing ./core/lib/dal/.)
];
};
};
in
{
zksync-era = pkgs.lib.makeScope pkgs.newScope (
self: pkgs.lib.filesystem.packagesFromDirectoryRecursive {
callPackage = package: params: self.callPackage package (params // {
inherit craneLib;
inherit coreCommonArgs;
inherit zkstackArgs;
inputs = inputs // { src = ./.; };
});
directory = ./etc/nix;
}
);
};
};
}