Skip to content
Draft
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
28 changes: 28 additions & 0 deletions .github/actions/setup-nix/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: 'Setup with Nix'
description: 'Install Nix and prepare devshell for Light Protocol'

inputs:
skip-devshell-build:
description: 'Skip building the devshell (for faster startup when only nix tools needed)'
required: false
default: 'false'

runs:
using: 'composite'
steps:
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main

- name: Enable Nix cache
uses: DeterminateSystems/magic-nix-cache-action@main

- name: Build devshell
if: inputs.skip-devshell-build != 'true'
shell: bash
run: |
nix develop ./nix/devenv --command echo "Devshell ready"

- name: Set environment
shell: bash
run: |
echo "IN_NIX_SHELL=true" >> $GITHUB_ENV
44 changes: 44 additions & 0 deletions .github/workflows/nix-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Nix Build Test

permissions:
contents: read

on:
pull_request:
paths:
- 'nix/**'
- '.github/workflows/nix-test.yml'
- '.github/actions/setup-nix/**'
workflow_dispatch:

jobs:
test-nix-devshell:
name: Test Nix Devshell
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Nix
uses: ./.github/actions/setup-nix

- name: Verify tools
run: |
nix develop ./nix/devenv --command bash -c '
echo "=== Tool Versions ==="
solana --version
anchor --version
go version
node --version
pnpm --version
echo "=== All tools working ==="
'

- name: Test cargo build-sbf
run: |
nix develop ./nix/devenv --command bash -c '
cd programs/system
cargo build-sbf 2>&1 | tail -5
'
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,6 @@ output1.txt
**/~/

expand.rs

# Separate target dirs for SBF builds (pinocchio vs anchor features)
target-*/
69 changes: 69 additions & 0 deletions nix/devenv/anchor.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{ lib
, stdenv
, fetchurl
, autoPatchelfHook
, zlib
, openssl
, glibc
}:

let
version = "0.31.1";

sources = {
x86_64-linux = {
url = "https://github.com/coral-xyz/anchor/releases/download/v${version}/anchor-${version}-x86_64-unknown-linux-gnu";
hash = "sha256-Xl+PwPdfLD3FzOsIKn9zXQm+IgdUApH/rTcOtbLclZs=";
};
x86_64-darwin = {
url = "https://github.com/coral-xyz/anchor/releases/download/v${version}/anchor-${version}-x86_64-apple-darwin";
hash = "sha256-MwGcRwS2x4toDyth5yJEiXKsZ6vokBnyCdCSAGhPTLs=";
};
aarch64-darwin = {
url = "https://github.com/coral-xyz/anchor/releases/download/v${version}/anchor-${version}-aarch64-apple-darwin";
hash = "sha256-ljxesAeqMwTXDV4H+Ng5AqHLiQLv7l3aRHzlSLk3lJQ=";
};
};

platform = stdenv.hostPlatform.system;
src = fetchurl {
inherit (sources.${platform}) url hash;
};

in stdenv.mkDerivation {
pname = "anchor";
inherit version src;

dontUnpack = true;

nativeBuildInputs = lib.optionals stdenv.isLinux [
autoPatchelfHook
];

buildInputs = lib.optionals stdenv.isLinux [
zlib
openssl
stdenv.cc.cc.lib
];

dontConfigure = true;
dontBuild = true;

installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp $src $out/bin/anchor
chmod +x $out/bin/anchor
runHook postInstall
'';

meta = with lib; {
description = "Anchor framework for Solana";
homepage = "https://anchor-lang.com";
license = licenses.asl20;
platforms = builtins.attrNames sources;
mainProgram = "anchor";
};

passthru = { inherit version; };
}
96 changes: 96 additions & 0 deletions nix/devenv/flake.lock

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

Loading
Loading