-
Notifications
You must be signed in to change notification settings - Fork 303
/
flake.nix
185 lines (177 loc) · 7.58 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
{
description = "A nix development shell and build environment for penumbra";
inputs = {
# nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
crane = {
url = "github:ipetkov/crane";
inputs = { nixpkgs.follows = "nixpkgs"; };
};
};
outputs = { self, nixpkgs, flake-utils, rust-overlay, crane, ... }:
flake-utils.lib.eachDefaultSystem
(system:
let
# Define versions of Penumbra and CometBFT
penumbraRelease = null; # Use the local working copy
# To update the cometbft hash values, run:
# nix-prefetch-git --url https://github.com/cometbft/cometbft --rev <tag>
# and review the output.
cometBftRelease = {
version = "0.37.9";
sha256 = "sha256-4LUdDlDog4kbiwyGo5fZEvtDXa6sIm+SKlSBWq1angc=";
vendorHash = "sha256-0iqI/Z8rqDyQ7JqSrsqA9kADqF6qZy8NxTDNjAYYHts=";
};
# Build grpcui from source, for Reflection v1 support.
# https://github.com/fullstorydev/grpcui/issues/322
# To update the grpcui hash values, run:
# nix-prefetch-git --url https://github.com/fullstorydev/grpcui --rev 483f037ec98b89200353c696d990324318f8df98
grpcUiRelease = {
version = "1.4.2-pre.1";
sha256 = "sha256-3vjJNa1bXoMGZXPRyVqhxYZPX5FDp8Efy+w6gdx0pXE=";
vendorHash = "sha256-j7ZJeO9vhjOoR8aOOJymDM6D7mPAJQoD4O6AyAsErRY=";
rev = "483f037ec98b89200353c696d990324318f8df98";
};
# Set up for Rust builds, pinned to the Rust toolchain version in the Penumbra repository
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
# Important environment variables so that the build can find the necessary libraries
PKG_CONFIG_PATH="${pkgs.openssl.dev}/lib/pkgconfig";
LIBCLANG_PATH="${pkgs.libclang.lib}/lib";
ROCKSDB_LIB_DIR="${pkgs.rocksdb.out}/lib";
in with pkgs; with pkgs.lib; let
# All the Penumbra binaries
penumbra = (craneLib.buildPackage {
pname = "penumbra";
src = cleanSourceWith {
src = if penumbraRelease == null then craneLib.path ./. else fetchFromGitHub {
owner = "penumbra-zone";
repo = "penumbra";
rev = "v${penumbraRelease.version}";
sha256 = "${penumbraRelease.sha256}";
};
filter = path: type:
# Retain non-rust asset files as build inputs:
# * no_lfs, param, bin: proving and verification parameters
# * zip: frontend bundled assets
# * sql: database schema files for indexing
# * csv: default genesis allocations for testnet generation
# * json: default validator info for testnet generation
(builtins.match ".*\.(no_lfs|param|bin|zip|sql|csv|json)$" path != null) ||
# ... as well as all the normal cargo source files:
(craneLib.filterCargoSources path type);
};
nativeBuildInputs = [ pkg-config ];
buildInputs = if stdenv.hostPlatform.isDarwin then
with pkgs.darwin.apple_sdk.frameworks; [clang openssl rocksdb SystemConfiguration CoreServices]
else
[clang openssl rocksdb];
inherit system PKG_CONFIG_PATH LIBCLANG_PATH ROCKSDB_LIB_DIR;
cargoExtraArgs = "-p pd -p pcli -p pclientd -p pindexer -p pmonitor";
meta = {
description = "A fully private proof-of-stake network and decentralized exchange for the Cosmos ecosystem";
homepage = "https://penumbra.zone";
license = [ licenses.mit licenses.asl20 ];
};
}).overrideAttrs (_: { doCheck = false; }); # Disable tests to improve build times
# CometBFT
cometbft = (buildGoModule rec {
pname = "cometbft";
version = cometBftRelease.version;
subPackages = [ "cmd/cometbft" ];
src = fetchFromGitHub {
owner = "cometbft";
repo = "cometbft";
rev = "v${cometBftRelease.version}";
hash = cometBftRelease.sha256;
};
vendorHash = cometBftRelease.vendorHash;
meta = {
description = "CometBFT (fork of Tendermint Core): A distributed, Byzantine fault-tolerant, deterministic state machine replication engine";
homepage = "https://github.com/cometbft/cometbft";
license = licenses.asl20;
};
}).overrideAttrs (_: { doCheck = false; }); # Disable tests to improve build times
# grpcui
grpcui = (buildGoModule rec {
pname = "grpcui";
version = grpcUiRelease.version;
subPackages = [ "cmd/grpcui" ];
src = fetchFromGitHub {
owner = "fullstorydev";
repo = "grpcui";
rev = "${grpcUiRelease.rev}";
hash = grpcUiRelease.sha256;
};
vendorHash = grpcUiRelease.vendorHash;
meta = {
description = "An interactive web UI for gRPC, along the lines of postman";
homepage = "https://github.com/fullstorydev/grpcui";
license = licenses.mit;
};
}).overrideAttrs (_: { doCheck = false; }); # Disable tests to improve build times
in rec {
packages = { inherit penumbra cometbft; };
apps = {
pd.type = "app";
pd.program = "${penumbra}/bin/pd";
pcli.type = "app";
pcli.program = "${penumbra}/bin/pcli";
pclientd.type = "app";
pclientd.program = "${penumbra}/bin/pclientd";
pindexer.type = "app";
pindexer.program = "${penumbra}/bin/pindexer";
pmonitor.type = "app";
pmonitor.program = "${penumbra}/bin/pmonitor";
cometbft.type = "app";
cometbft.program = "${cometbft}/bin/cometbft";
};
defaultPackage = symlinkJoin {
name = "penumbra-and-cometbft";
paths = [ penumbra cometbft ];
};
devShells.default = craneLib.devShell {
inherit LIBCLANG_PATH ROCKSDB_LIB_DIR;
inputsFrom = [ penumbra ];
packages = [
buf
cargo-nextest
cargo-release
cargo-watch
glibcLocales # for postgres initdb locale support
cometbft
grafana
grpcurl
grpcui
just
mdbook
mdbook-katex
mdbook-mermaid
mdbook-linkcheck
nix-prefetch-scripts
postgresql
process-compose
prometheus
protobuf
rocksdb
rsync
sqlfluff
];
shellHook = ''
export LIBCLANG_PATH=${LIBCLANG_PATH}
export RUST_SRC_PATH=${pkgs.rustPlatform.rustLibSrc} # Required for rust-analyzer
export ROCKSDB_LIB_DIR=${ROCKSDB_LIB_DIR}
'';
};
}
);
}