diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3be5498..9eaa9a4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: os: [ubuntu-latest] steps: - uses: actions/checkout@v3 - - uses: cachix/install-nix-action@v20 + - uses: cachix/install-nix-action@v26 - name: Setup Cachix uses: cachix/cachix-action@v12 with: @@ -59,37 +59,37 @@ jobs: - anchor-0_28 - anchor-0_29 - anchor - - saber-devenv - steps: - - uses: actions/checkout@v3 - - uses: cachix/install-nix-action@v20 - - name: Setup Cachix - uses: cachix/cachix-action@v12 - with: - name: saber - authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - - run: nix build --show-trace --print-build-logs .#${{ matrix.package }} - - build-packages-linux-only: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - package: - - solana-1_8-full - - solana-1_9-full - - solana-1_10-full - - solana-1_11-full - - solana-1_13-full - solana-1_17-full - solana-full + - saber-devenv steps: - uses: actions/checkout@v3 - - uses: cachix/install-nix-action@v20 + - uses: cachix/install-nix-action@v26 - name: Setup Cachix uses: cachix/cachix-action@v12 with: name: saber authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - run: nix build --show-trace --print-build-logs .#${{ matrix.package }} + + # build-packages-linux-only: + # runs-on: ${{ matrix.os }} + # strategy: + # fail-fast: false + # matrix: + # os: [ubuntu-latest] + # package: + # - solana-1_8-full + # - solana-1_9-full + # - solana-1_10-full + # - solana-1_11-full + # - solana-1_13-full + # steps: + # - uses: actions/checkout@v3 + # - uses: cachix/install-nix-action@v26 + # - name: Setup Cachix + # uses: cachix/cachix-action@v12 + # with: + # name: saber + # authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" + # - run: nix build --show-trace --print-build-logs .#${{ matrix.package }} diff --git a/packages/solana/default.nix b/packages/solana/default.nix index cbd84f4..48326a0 100644 --- a/packages/solana/default.nix +++ b/packages/solana/default.nix @@ -5,7 +5,10 @@ }: let mkSolana = ( - { rust ? rustStable, cargoOutputHashes ? { }, ... }@args: + { rust ? rustStable + , cargoOutputHashes ? { } + , ... + }@args: import ./solana-packages.nix { inherit pkgs rust darwinPackages cargoOutputHashes; inherit (args) version githubSha256; diff --git a/packages/solana/solana.nix b/packages/solana/solana.nix index 3420d72..ae16160 100644 --- a/packages/solana/solana.nix +++ b/packages/solana/solana.nix @@ -1,3 +1,4 @@ +# Some of this file is taken from https://github.com/NixOS/nixpkgs/blob/nixpkgs-unstable/pkgs/applications/blockchains/solana/default.nix { name ? "solana" , lib , validatorOnly ? false @@ -12,6 +13,8 @@ , fetchFromGitHub , stdenv , darwinPackages +, darwin +, libcxx , protobuf , rustfmt , cargoLockFile @@ -19,6 +22,7 @@ , githubSha256 , perl , cargoOutputHashes +, rocksdb , # Taken from https://github.com/solana-labs/solana/blob/master/scripts/cargo-install-all.sh#L84 solanaPkgs ? [ "solana" @@ -52,6 +56,10 @@ ] }: +let + inherit (darwin.apple_sdk_11_0) Libsystem; + inherit (darwin.apple_sdk_11_0.frameworks) System IOKit AppKit Security; +in rustPlatform.buildRustPackage rec { pname = name; inherit version; @@ -71,20 +79,46 @@ rustPlatform.buildRustPackage rec { 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"; - nativeBuildInputs = [ clang llvm pkg-config protobuf rustfmt perl ]; buildInputs = - ([ openssl zlib libclang ] ++ (lib.optionals stdenv.isLinux [ udev ])) - ++ darwinPackages; + [ + openssl + rustPlatform.bindgenHook + zlib + libclang + rocksdb + ] + ++ lib.optionals stdenv.isLinux [ udev ] + ++ lib.optionals stdenv.isDarwin [ + libcxx + IOKit + Security + AppKit + System + Libsystem + ]; strictDeps = true; + postInstall = '' + mkdir -p $out/bin/sdk/bpf + cp -a ./sdk/bpf/* $out/bin/sdk/bpf/ + ''; + # this is too slow doCheck = false; + # Used by build.rs in the rocksdb-sys crate. If we don't set these, it would + # try to build RocksDB from source. + 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; { homepage = "https://solana.com/"; description =