forked from penumbra-zone/penumbra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
124 lines (119 loc) · 4.97 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
{
description = "A nix development shell and build environment for penumbra";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
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
cometBftRelease = {
version = "0.37.5";
sha256 = "sha256-wNVHsifieAtZgedavCEJLgG0kRDqUhG4Lk5ciTPoNzI=";
vendorHash = "sha256-JPEGMa0HDesEtKFvgLUP2UfTB0DlParepE2p+n06Igc=";
};
# 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 proving and verification parameters, and no-lfs marker file ...
(builtins.match ".*\.(no_lfs|param||bin)$" path != null) ||
# ... as well as all the normal cargo source files:
(craneLib.filterCargoSources path type);
};
nativeBuildInputs = [ pkg-config ];
buildInputs = [ clang openssl rocksdb ];
inherit system PKG_CONFIG_PATH LIBCLANG_PATH ROCKSDB_LIB_DIR;
cargoExtraArgs = "-p pd -p pcli -p pclientd";
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
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";
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 = [
cargo-nextest
cargo-watch
cometbft
just
postgresql
protobuf
rocksdb
];
shellHook = ''
export LIBCLANG_PATH=${LIBCLANG_PATH}
export RUST_SRC_PATH=${pkgs.rustPlatform.rustLibSrc} # Required for rust-analyzer
export ROCKSDB_LIB_DIR=${ROCKSDB_LIB_DIR}
'';
};
}
);
}