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

Yn solana #514

Open
wants to merge 3 commits 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
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
TEST_COUNT ?= 10
COVERAGE_FILE ?= coverage.out
export PROJECT_SERUM_VERSION ?=v0.29.0
export PROJECT_SERUM_IMAGE ?= backpackapp/build:$(PROJECT_SERUM_VERSION)

# Detect the system architecture
ARCH := $(shell uname -m)
Expand Down Expand Up @@ -70,3 +72,6 @@ ensure_golangcilint_1_62_2:

ensure_protoc_28_0:
@$(PROTOC_BIN) --version | grep -q 'libprotoc 28.0' || (echo "Please use protoc 28.0, (make install-protoc)" && exit 1)

anchor_shell:
docker run --rm -it -v $(shell pwd):/workdir --entrypoint bash ${PROJECT_SERUM_IMAGE}
96 changes: 96 additions & 0 deletions flake.lock

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

26 changes: 26 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
description = "Solana integration";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
};

outputs = inputs@{ self, nixpkgs, rust-overlay, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; overlays = [ rust-overlay.overlays.default ]; };
solanaPkgs = pkgs.callPackage ./solana.nix {};
in rec {
devShells = {
default = pkgs.callPackage ./shell.nix {};
solana-cli = solanaPkgs.solana-cli-shell;
};

packages = {
solana-test-validator = solanaPkgs.solana-test-validator;
solana-cli-env = solanaPkgs.solana-cli-env;
};
});
}
116 changes: 116 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{ stdenv, pkgs, lib }:
let
version = "v2.0.18";
getBinDerivation =
{
name,
filename,
sha256,
}:
pkgs.stdenv.mkDerivation rec {
inherit name;
url = "https://github.com/anza-xyz/agave/releases/download/${version}/${filename}";
src = pkgs.fetchzip {
inherit url sha256;
};

installPhase = ''
mkdir -p $out/bin
ls -lah $src
cp -r $src/bin/* $out/bin
'';
};

# It provides two derivations, one for x86_64-linux and another for aarch64-apple-darwin.
# Each derivation downloads the corresponding Solana release.

# The SHA256 hashes below are automatically updated by action.(dependency-updates.yml)
# The update script(./scripts/update-solana-nix-hashes.sh) looks for the BEGIN and END markers to locate the lines to modify.
# Do not modify these markers or the lines between them manually.
solanaBinaries = {
x86_64-linux = getBinDerivation {
name = "solana-cli-x86_64-linux";
filename = "solana-release-x86_64-unknown-linux-gnu.tar.bz2";
### BEGIN_LINUX_SHA256 ###
sha256 = "sha256-3FW6IMZeDtyU4GTsRIwT9BFLNzLPEuP+oiQdur7P13s=";
### END_LINUX_SHA256 ###
};
aarch64-apple-darwin = getBinDerivation {
name = "solana-cli-aarch64-apple-darwin";
filename = "solana-release-aarch64-apple-darwin.tar.bz2";
### BEGIN_DARWIN_SHA256 ###
sha256 = "sha256-6VjycYU0NU0evXoqtGAZMYGHQEKijofnFQnBJNVsb6Q=";
### END_DARWIN_SHA256 ###
};
};
in
pkgs.mkShell {
nativeBuildInputs = with pkgs; [
(rust-bin.stable.latest.default.override { extensions = ["rust-src"]; })
# lld_11
llvm_12
stdenv.cc.cc.lib
pkg-config
openssl

# Solana
# solana.solana-full
# spl-token-cli
# anchor

# Golang
# Keep this golang version in sync with the version in .tool-versions please
go_1_23
gopls
delve
golangci-lint
gotools
kubernetes-helm

# NodeJS + TS
nodePackages.typescript
nodePackages.typescript-language-server
nodePackages.npm
nodePackages.pnpm
# Keep this nodejs version in sync with the version in .tool-versions please
nodejs-18_x
(yarn.override { nodejs = nodejs-18_x; })
python3
# ] ++ lib.optionals stdenv.isLinux [
# # ledger specific packages
# libudev-zero
# libusb1
# ];
] ++ pkgs.lib.optionals pkgs.stdenv.isLinux [
libudev-zero
libusb1
solanaBinaries.x86_64-linux
] ++ pkgs.lib.optionals (pkgs.stdenv.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) [
solanaBinaries.aarch64-apple-darwin
];
RUST_BACKTRACE = "1";

LD_LIBRARY_PATH = lib.makeLibraryPath [pkgs.zlib stdenv.cc.cc.lib]; # lib64

# Avoids issues with delve
CGO_CPPFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0";

# shellHook = ''
# # install gotestloghelper
# go install github.com/smartcontractkit/chainlink-testing-framework/tools/gotestloghelper@latest
# '';
shellHook = ''
echo "===================================================="
echo "Welcome to the combined development shell."
echo "Current environment: $(uname -a)"
echo "You are using the package for ${pkgs.stdenv.hostPlatform.system}."
echo "----------------------------------------------------"
echo "Solana CLI information:"
solana --version || echo "Solana CLI not available."
solana config get || echo "Solana config not available."
echo "----------------------------------------------------"

# Install gotestloghelper
go install github.com/smartcontractkit/chainlink-testing-framework/tools/gotestloghelper@latest
'';
}
Loading