-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
119 lines (106 loc) · 3.19 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
{
description = "Solana binaries and tools";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane = {
url = "github:ipetkov/crane";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
crane,
rust-overlay,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [(import rust-overlay)];
};
rustOverlay = pkgs.rust-bin.stable.latest.default;
inherit (pkgs) lib;
craneLib = (crane.mkLib pkgs).overrideToolchain rustOverlay;
# Common arguments can be set here to avoid repeating them later
commonArgs = {
pname = "solana-cli";
version = "2.0.9";
strictDeps = true;
OPENSSL_NO_VENDOR = "1";
};
solana-packages = [
"agave-install"
"agave-ledger-tool"
"agave-validator"
"agave-install-init"
"agave-watchtower"
"solana"
"solana-bench-tps"
"solana-faucet"
"solana-gossip"
"solana-keygen"
"solana-log-analyzer"
"solana-net-shaper"
"solana-dos"
"solana-stake-accounts"
"solana-test-validator"
"solana-tokens"
"solana-genesis"
];
cargoBuildFlags = lib.concatStrings (builtins.map (n: "--bin=${n} ") solana-packages);
solana-bins = craneLib.mkCargoDerivation (commonArgs
// {
cargoArtifacts = null;
src = pkgs.fetchFromGitHub {
owner = "anza-xyz";
repo = "agave";
rev = "v${commonArgs.version}";
sha256 = "sha256-SrfhLchtWfU2DN5EypvbvI4a1/fB5RMKpRH6vKJ8sA0=";
# sha256 = lib.fakeHash;
fetchSubmodules = true;
};
doCheck = false;
buildInputs = with pkgs; [
openssl
zlib
libclang.lib
hidapi
udev
rocksdb
];
nativeBuildInputs = with pkgs; [
pkg-config
protobuf
rustfmt
rustPlatform.bindgenHook
perl
];
ROCKSDB_LIB_DIR = "${pkgs.rocksdb}/lib";
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
BINDGEN_EXTRA_CLANG_ARGS = "-isystem ${pkgs.llvmPackages.libclang.lib}/lib/clang/${lib.getVersion pkgs.clang}/include";
buildPhaseCargoCommand = "cargo build --release ${cargoBuildFlags}";
doInstallCargoArtifacts = false;
installPhase = ''
mkdir -p $out/bin/sdk/sbf
find target/release -maxdepth 1 -executable -type f -exec cp -a {} $out/bin/ \;
'';
});
in {
######################################################
### Build packages ###
######################################################
packages = {
default = solana-bins;
};
apps.default = flake-utils.lib.mkApp {drv = solana-bins;};
});
}