diff options
author | netfox <say-hi@netfox.rip> | 2023-04-17 17:43:49 +0200 |
---|---|---|
committer | Yt <happysalada@proton.me> | 2023-04-29 11:18:27 -0400 |
commit | a49eb1726cdaa0bec129a934e97f4a1c9481bd33 (patch) | |
tree | bce0a26a9ddf698455abf33f4869bce76a504db7 /pkgs/applications/blockchains | |
parent | d9b04ae5de5e6bd9021fc353ba58454b9333ec01 (diff) |
solana-cli: 1.10.9 -> 1.14.17
Apart from putting the package up-to-date in term of versions, a few modifications have been made, namely: 1) renamed package: solana-cli-testnet -> solana-cli 2) removed custom update script in favor of nix-update-script 3) made the derivation build by default all the binaries in the solana repository, as most of them are useful in terms of development and a few important ones were missing
Diffstat (limited to 'pkgs/applications/blockchains')
-rw-r--r-- | pkgs/applications/blockchains/solana/default.nix | 107 | ||||
-rw-r--r-- | pkgs/applications/blockchains/solana/pin.json | 5 | ||||
-rwxr-xr-x | pkgs/applications/blockchains/solana/update.sh | 33 |
3 files changed, 78 insertions, 67 deletions
diff --git a/pkgs/applications/blockchains/solana/default.nix b/pkgs/applications/blockchains/solana/default.nix index 4886720218638..b21e945b1aedf 100644 --- a/pkgs/applications/blockchains/solana/default.nix +++ b/pkgs/applications/blockchains/solana/default.nix @@ -2,22 +2,54 @@ , fetchFromGitHub , lib , rustPlatform -, IOKit -, Security -, AppKit -, pkg-config +, darwin , udev -, zlib , protobuf +, libcxx +, rocksdb +, pkg-config +, openssl +, nix-update-script +# Taken from https://github.com/solana-labs/solana/blob/master/scripts/cargo-install-all.sh#L84 +, solanaPkgs ? [ + "solana" + "solana-bench-tps" + "solana-faucet" + "solana-gossip" + "solana-install" + "solana-keygen" + "solana-log-analyzer" + "solana-net-shaper" + "solana-sys-tuner" + "rbpf-cli" + "solana-validator" + "solana-ledger-tool" + "cargo-build-bpf" + "cargo-test-bpf" + "solana-dos" + "solana-install-init" + "solana-stake-accounts" + "solana-test-validator" + "solana-tokens" + "solana-watchtower" + "cargo-test-sbf" + "cargo-build-sbf" +] ++ [ + # 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; + version = "1.14.17"; + sha256 = "sha256-pYbnEF8MgF7fCBf/MOPT//UCeOQj9tuIkDj8UIVFz3E="; + cargoSha256 = "sha256-n9nuBiKV3FCgq5fJ5BuqIIAp1yZ6IO+zHjrMaUBfgzs="; + + inherit (darwin.apple_sdk_11_0) Libsystem; + inherit (darwin.apple_sdk_11_0.frameworks) System IOKit AppKit Security; in rustPlatform.buildRustPackage rec { - pname = "solana-testnet-cli"; + pname = "solana-cli"; inherit version cargoSha256; src = fetchFromGitHub { @@ -27,35 +59,52 @@ rustPlatform.buildRustPackage rec { inherit sha256; }; - buildAndTestSubdir = "cli"; + strictDeps = true; + verifyCargoDeps = true; + cargoBuildFlags = builtins.map (n: "--bin=${n}") solanaPkgs; - nativeBuildInputs = lib.optionals stdenv.isLinux [ protobuf pkg-config ]; - buildInputs = lib.optionals stdenv.isLinux [ udev zlib ] ++ lib.optionals stdenv.isDarwin [ IOKit Security AppKit ]; - - # check phase fails - # on darwin with missing framework System. This framework is not available in nixpkgs - # on linux with some librocksdb-sys compilation error + # Even tho the tests work, a shit ton of them try to connect to a local RPC + # or access internet in other ways, eventually failing due to Nix sandbox. + # Maybe we could restrict the check to the tests that don't require an RPC, + # but judging by the quantity of tests, that seems like a lengthty work and + # I'm not in the mood ((ΦωΦ)) doCheck = false; - # all the following are needed for the checkphase - # nativeCheckInputs = lib.optionals stdenv.isDarwin [ pkg-config rustfmt ]; - # Needed to get openssl-sys to use pkg-config. - # OPENSSL_NO_VENDOR = 1; - # OPENSSL_LIB_DIR = "${lib.getLib openssl}/lib"; - # OPENSSL_DIR="${lib.getDev openssl}"; - # LLVM_CONFIG_PATH="${llvm}/bin/llvm-config"; - # LIBCLANG_PATH="${llvmPackages.libclang.lib}/lib"; + nativeBuildInputs = [ protobuf pkg-config ]; + buildInputs = [ openssl rustPlatform.bindgenHook ] + ++ lib.optionals stdenv.isLinux [ udev ] + ++ lib.optionals stdenv.isDarwin [ + libcxx + IOKit + Security + AppKit + System + Libsystem ]; + + postInstall = '' + mkdir -p $out/bin/sdk/bpf + cp -a ./sdk/bpf/* $out/bin/sdk/bpf/ + ''; + # Used by build.rs in the rocksdb-sys crate. If we don't set these, it would # try to build RocksDB from source. - # ROCKSDB_INCLUDE_DIR="${rocksdb}/include"; - # ROCKSDB_LIB_DIR="${rocksdb}/lib"; + ROCKSDB_LIB_DIR="${rocksdb}/lib"; + + # Require this on darwin otherwise the compiler starts rambling about missing + # cmath functions + CPPFLAGS=lib.optionals stdenv.isDarwin "-isystem ${lib.getDev libcxx}/include/c++/v1"; + LDFLAGS=lib.optionals stdenv.isDarwin "-L${lib.getLib libcxx}/lib"; + + # If set, always finds OpenSSL in the system, even if the vendored feature is enabled. + OPENSSL_NO_VENDOR = 1; 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; [ happysalada ]; + maintainers = with maintainers; [ netfox happysalada ]; platforms = platforms.unix; }; - passthru.updateScript = ./update.sh; + + passthru.updateScript = nix-update-script { }; } diff --git a/pkgs/applications/blockchains/solana/pin.json b/pkgs/applications/blockchains/solana/pin.json deleted file mode 100644 index 34ef479795927..0000000000000 --- a/pkgs/applications/blockchains/solana/pin.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "version": "1.10.9", - "sha256": "sha256-y7+ogMJ5E9E/+ZaTCHWOQWG7iR+BGuVqvlNUDT++Ghc=", - "cargoSha256": "sha256-7EULmmztt+INvSdluvvX5xbE2hWKAmHiW0MEYIPNPw4=" -} diff --git a/pkgs/applications/blockchains/solana/update.sh b/pkgs/applications/blockchains/solana/update.sh deleted file mode 100755 index ffd8b0010cc26..0000000000000 --- a/pkgs/applications/blockchains/solana/update.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env nix-shell -#! nix-shell -i oil -p jq sd nix-prefetch-github ripgrep - -# TODO set to `verbose` or `extdebug` once implemented in oil -shopt --set xtrace -# we need failures inside of command subs to get the correct cargoSha256 -shopt --unset inherit_errexit - -const directory = $(dirname $0 | xargs realpath) -const owner = "solana-labs" -const repo = "solana" -const latest_rev = $(curl -q https://api.github.com/repos/${owner}/${repo}/releases/latest | \ - jq -r '.tag_name') -const latest_version = $(echo $latest_rev | sd 'v' '') -const current_version = $(jq -r '.version' $directory/pin.json) -if ("$latest_version" === "$current_version") { - echo "solana is already up-to-date" - return 0 -} else { - const tarball_meta = $(nix-prefetch-github $owner $repo --rev "$latest_rev") - const tarball_hash = "sha256-$(echo $tarball_meta | jq -r '.sha256')" - - jq ".version = \"$latest_version\" | \ - .\"sha256\" = \"$tarball_hash\" | \ - .\"cargoSha256\" = \"\"" $directory/pin.json | sponge $directory/pin.json - - const new_cargo_sha256 = $(nix-build -A solana-testnet 2>&1 | \ - tail -n 2 | \ - head -n 1 | \ - sd '\s+got:\s+' '') - - jq ".cargoSha256 = \"$new_cargo_sha256\"" $directory/pin.json | sponge $directory/pin.json -} |