nixpkgs/pkgs/applications/blockchains/solana-validator/default.nix
2022-09-16 23:24:07 -04:00

91 lines
2.2 KiB
Nix

# largely inspired from https://github.com/saber-hq/saber-overlay/blob/master/packages/solana/solana.nix
{ stdenv
, fetchFromGitHub
, lib
, rustPlatform
, IOKit
, Security
, AppKit
, pkg-config
, udev
, zlib
, protobuf
, clang
, llvm
, openssl
, libclang
, rustfmt
, perl
, hidapi
, solanaPkgs ? [
"solana"
"solana-bench-tps"
"solana-faucet"
"solana-gossip"
"solana-install"
"solana-keygen"
"solana-ledger-tool"
"solana-log-analyzer"
"solana-net-shaper"
"solana-sys-tuner"
"solana-validator"
"cargo-build-bpf"
"cargo-test-bpf"
"solana-dos"
"solana-install-init"
"solana-stake-accounts"
"solana-test-validator"
"solana-tokens"
"solana-watchtower"
] ++ [
# XXX: Ensure `solana-genesis` is built LAST!
# See https://github.com/solana-labs/solana/issues/5826
"solana-genesis"
]
}:
let
pinData = lib.importJSON ./pin.json;
version = pinData.version;
sha256 = pinData.sha256;
cargoSha256 = pinData.cargoSha256;
in
rustPlatform.buildRustPackage rec {
pname = "solana-validator";
inherit version;
src = fetchFromGitHub {
owner = "solana-labs";
repo = "solana";
rev = "v${version}";
inherit sha256;
};
# partly inspired by https://github.com/obsidiansystems/solana-bridges/blob/develop/default.nix#L29
inherit cargoSha256;
verifyCargoDeps = true;
cargoBuildFlags = builtins.map (n: "--bin=${n}") solanaPkgs;
# weird errors. see https://github.com/NixOS/nixpkgs/issues/52447#issuecomment-852079285
LIBCLANG_PATH = "${libclang.lib}/lib";
BINDGEN_EXTRA_CLANG_ARGS =
"-isystem ${libclang.lib}/lib/clang/${lib.getVersion clang}/include";
LLVM_CONFIG_PATH = "${llvm}/bin/llvm-config";
nativeBuildInputs = [ clang llvm pkg-config protobuf rustfmt perl ];
buildInputs =
[ openssl zlib libclang hidapi ] ++ (lib.optionals stdenv.isLinux [ udev ]);
strictDeps = true;
doCheck = false;
meta = with lib; {
description = "Web-Scale Blockchain for fast, secure, scalable, decentralized apps and marketplaces. ";
homepage = "https://solana.com";
license = licenses.asl20;
maintainers = with maintainers; [ adjacentresearch ];
platforms = platforms.unix;
};
passthru.updateScript = ./update.sh;
}