Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nix: nixpkgs release-22.11, solana validator 1.15.2, /usr/bin/env #52

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
watch_file flake.nix
watch_file shell.nix
watch_file flake.lock
use flake
13 changes: 7 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{
description = "Pyth Agent";
nixConfig.bash-prompt = "\[nix@pyth-agent\]$ ";
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
inputs.nixpkgs.url = github:NixOS/nixpkgs/release-22.11;
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.fenix.url = "github:nix-community/fenix";
inputs.fenix.inputs.nixpkgs.follows = "nixpkgs";
Expand Down
93 changes: 93 additions & 0 deletions nix/solana-validator.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# 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
version = "1.15.2";
extraOutputHashes = {
"typed-hpml-0.2.2" = "00000000000000000";
};
cargoSha256 = "sha256-G3LvsQqEFNBB0+T23+CWloOMMI8OQf2zFsCkXUP/hGU=";
sha256 = "sha256-rg1mshIQ5WibI8YEBSqLRhWiTcpoBNgFQjE0SZ12jqc=";
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;
}
2 changes: 1 addition & 1 deletion scripts/init_key_store.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -e

# This script initializes the keystore directory used by the agent binary.
Expand Down
25 changes: 20 additions & 5 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
{ pkgs ? import <nixpkgs> {}
{ pkgs ? import <nixpkgs> { }
, ...
}:
let
solana-validator-bumped = pkgs.callPackage ./nix/solana-validator.nix {
inherit (pkgs.apple_sdk.frameworks) IOKit Security AppKit;
rustPlatform = pkgs.rustPackages_1_66.rustPlatform;
};

with pkgs; mkShell {
in
with pkgs;
mkShell rec {
buildInputs = [
clang
llvmPackages.libclang
git # the shell may be using a different glibc which upsets common CLI tools
openssl
pkgconfig
rustup
python3
poetry
solana-validator-bumped
stdenv.cc
stdenv.cc.cc.lib # libstdc++.so.6
];

shellHook = ''
export LIBCLANG_PATH="${llvmPackages.libclang.lib}/lib";
'';
# Explicitly tell the environment about all *.so's (libstdcxx, libclang end up in the path this way)
LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;

# Tell the Rust build where libclang lives
LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
}