diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..b7313e3f --- /dev/null +++ b/flake.lock @@ -0,0 +1,96 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1751984180, + "narHash": "sha256-LwWRsENAZJKUdD3SpLluwDmdXY9F45ZEgCb0X+xgOL0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9807714d6944a957c2e036f84b0ff8caf9930bc0", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1744536153, + "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1752201818, + "narHash": "sha256-d8KczaVT8WFEZdWg//tMAbv8EDyn2YTWcJvSY8gqKBU=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "bd8f8329780b348fedcd37b53dbbee48c08c496d", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..e37b3b7e --- /dev/null +++ b/flake.nix @@ -0,0 +1,93 @@ +{ + description = "Solana Toolbox CLI - A toolbox for interacting with Solana programs"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + rust-overlay.url = "github:oxalica/rust-overlay"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, rust-overlay, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { + inherit system overlays; + }; + + rustToolchain = pkgs.rust-bin.stable.latest.default.override { + extensions = [ "rust-src" "rustfmt" "clippy" ]; + }; + + # Native build inputs for Solana development + nativeBuildInputs = with pkgs; [ + pkg-config + openssl + rustToolchain + ]; + + # Build inputs for Solana development + buildInputs = with pkgs; [ + openssl + libudev-zero + libusb1 + ] ++ lib.optionals stdenv.isDarwin [ + darwin.apple_sdk.frameworks.AppKit + darwin.apple_sdk.frameworks.IOKit + ]; + + # Environment variables for the build + env = { + OPENSSL_NO_VENDOR = "1"; + OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib"; + OPENSSL_INCLUDE_DIR = "${pkgs.openssl.dev}/include"; + }; + + in + { + packages = { + default = self.packages.${system}.solana-toolbox-cli; + + solana-toolbox-cli = pkgs.rustPlatform.buildRustPackage { + pname = "solana-toolbox-cli"; + version = "0.4.2"; + + src = ./solana_toolbox_cli; + + cargoLock = { + lockFile = ./solana_toolbox_cli/Cargo.lock; + }; + + inherit nativeBuildInputs buildInputs; + inherit env; + + # Skip tests during build as they may require network access + doCheck = false; + + meta = with pkgs.lib; { + description = "Toolbox for interacting with Solana programs through CLI"; + homepage = "https://github.com/your-username/solana-toolbox"; + license = licenses.mit; + maintainers = [ ]; + platforms = platforms.all; + }; + }; + }; + + devShells.default = pkgs.mkShell { + inherit buildInputs nativeBuildInputs; + inherit env; + + shellHook = '' + echo "Solana Toolbox CLI development environment" + echo "Available commands:" + echo " cargo build --release" + echo " cargo test" + echo " cargo run -- --help" + ''; + }; + + # Formatter for nix files + formatter = pkgs.nixpkgs-fmt; + }); +} \ No newline at end of file