Skip to content

Conversation

hxrts
Copy link
Contributor

@hxrts hxrts commented Jul 8, 2025

tested and working on macos. needs to be built and hash added on a linux machine to complete linux support

@hxrts hxrts requested a review from Pacman99 July 8, 2025 21:43
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @hxrts, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the project's capabilities by adding full support for Solana blockchain development. It provides a self-contained, reproducible environment for building and testing Solana programs using Nix, complete with essential tools, detailed documentation, and a convenient project template. The primary focus is on establishing a robust macOS development experience, with a clear path for expanding Linux compatibility.

Highlights

  • Solana Development Environment: This pull request introduces a comprehensive Nix-based development environment for Solana, integrating Solana CLI (v2.0.22), Anchor framework (v0.31.1), and platform tools (v1.48) essential for SBF program compilation. This setup aims to provide a consistent and reproducible environment for Solana developers.
  • Nix Package Integration: New Nix derivations have been added in packages/solana-tools.nix to define and manage the Solana node, Anchor CLI, and supporting tools. These are then integrated into the main packages/default.nix and the default development shell, ensuring all necessary dependencies and environment variables are correctly configured upon entering the shell.
  • Comprehensive Documentation and Templates: A detailed guide (docs/guides/solana-development.md) has been added, covering quick start instructions, environment setup, Anchor usage, Solana CLI commands, SBF program development, and configuration. Additionally, a new Nix flake template (templates/solana-development/flake.nix) is provided to enable quick project initialization with the pre-configured Solana environment.
  • macOS Support and Future Linux Expansion: The changes include specific configurations for macOS, such as MACOSX_DEPLOYMENT_TARGET and RUSTFLAGS, to ensure proper compilation and linking on Apple Silicon and Intel Macs. The PR description notes that while tested and working on macOS, Linux support requires building and adding hashes on a Linux machine.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds comprehensive support for Solana development, including Nix packages for the Solana node, Anchor, and various dependencies, primarily for macOS. I've identified a few issues:

  • Critical: Placeholder SHA256 hashes for Linux builds will cause failures on that platform. These must be updated.
  • Medium: The script logic for detecting the anchor idl command is fragile and should be made more robust.
  • High: The documentation provides misleading examples for customizing the development environment, which could lead to broken configurations for users.

Comment on lines +47 to +51
sha256 = if pkgs.stdenv.isDarwin then
"sha256-upgxwAEvh11+IKVQ1FaZGlx8Z8Ps0CEScsbu4Hv3WH0=" # v2.0.22 macOS ARM64 hash
else
"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; # TODO: Get correct Linux hash with: nix store prefetch-file --json https://github.com/anza-xyz/agave/releases/download/v2.0.22/solana-release-x86_64-unknown-linux-gnu.tar.bz2
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The sha256 for the Linux build of solana-release is a placeholder. This will cause the build to fail on Linux systems. While the PR description indicates this is known, it's a critical issue that must be resolved for this feature to be complete.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leaving this for a subsequent PR

Comment on lines +59 to +63
sha256 = if pkgs.stdenv.isDarwin then
"sha256-eZ5M/O444icVXIP7IpT5b5SoQ9QuAcA1n7cSjiIW0t0=" # v1.48 macOS ARM64 hash
else
"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; # TODO: Get correct Linux hash with: nix store prefetch-file --json https://github.com/anza-xyz/platform-tools/releases/download/v1.48/platform-tools-linux-x86_64.tar.bz2
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Similar to the solana-release package, the sha256 for the Linux build of platform-tools is a placeholder. This will cause builds to fail on Linux.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leaving this for a subsequent PR

- docs/guides/solana-development.md: Use overrideAttrs instead of override to properly extend shell configuration without breaking zero.nix environment setup
- packages/solana-tools.nix: Improve idl command detection to match whole words only, preventing false positives with substrings like 'my-idl-program'
inherit (solana-tools) solana-node anchor setup-solana nightly-rust anchor-wrapper solana-tools;
};

devShells.default = pkgs.mkShell {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally prefer using numtide/devshell for this, it makes the code cleaner and we could also export a devshellModule for users to import

Comment on lines +167 to +173
#!/bin/bash
export PLATFORM_TOOLS_DIR="$out/platform-tools"
export SBF_SDK_PATH="$out/platform-tools"
export PATH="$out/platform-tools/rust/bin:$out/platform-tools/llvm/bin:\$PATH"
exec "$out/bin/.$tool-original" "\$@"
EOF
chmod +x "$out/bin/$tool"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are tools in nixpkgs to help with this, makeWrapper and wrapProgram. The second one will handling the in-place wrapping for you by moving the original executable into $out/bin/.$tool-unwrapped. Theres also a --prefix option that handles the PATH=...:$PATH for you.
https://nixos.org/manual/nixpkgs/stable/#fun-makeWrapper
https://nixos.org/manual/nixpkgs/stable/#fun-wrapProgram

@Pacman99 Pacman99 merged commit cefa25b into main Jul 14, 2025
1 check passed
@Pacman99 Pacman99 deleted the sam-solana branch July 14, 2025 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants