From 31ed54dab458cb3c0a6472f3e508ccdc7a9b4d79 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Tue, 4 Nov 2025 06:36:04 +0000 Subject: moved to flakes --- grasp-audit/QUICK_START.md | 4 +- grasp-audit/README.md | 3 ++ grasp-audit/flake.lock | 96 ++++++++++++++++++++++++++++++++++++++++++++++ grasp-audit/flake.nix | 66 +++++++++++++++++++++++++++++++ grasp-audit/shell.nix | 38 ------------------ 5 files changed, 167 insertions(+), 40 deletions(-) create mode 100644 grasp-audit/flake.lock create mode 100644 grasp-audit/flake.nix delete mode 100644 grasp-audit/shell.nix (limited to 'grasp-audit') diff --git a/grasp-audit/QUICK_START.md b/grasp-audit/QUICK_START.md index 47e848e..d4ee494 100644 --- a/grasp-audit/QUICK_START.md +++ b/grasp-audit/QUICK_START.md @@ -11,7 +11,7 @@ ```bash # Enter development shell cd grasp-audit -nix-shell +nix develop # Build the project cargo build @@ -135,7 +135,7 @@ async fn main() -> Result<()> { **Solution (NixOS):** ```bash -nix-shell # Use the provided shell.nix +nix develop # Use the provided flake.nix ``` **Solution (Other Linux):** diff --git a/grasp-audit/README.md b/grasp-audit/README.md index 558e201..b49ad11 100644 --- a/grasp-audit/README.md +++ b/grasp-audit/README.md @@ -124,6 +124,9 @@ cargo run --example simple_audit ## Testing ```bash +# Enter dev environment (NixOS) +nix develop + # Run unit tests cargo test diff --git a/grasp-audit/flake.lock b/grasp-audit/flake.lock new file mode 100644 index 0000000..d014800 --- /dev/null +++ b/grasp-audit/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": 1762111121, + "narHash": "sha256-4vhDuZ7OZaZmKKrnDpxLZZpGIJvAeMtK6FKLJYUtAdw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b3d51a0365f6695e7dd5cdf3e180604530ed33b4", + "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": 1762223900, + "narHash": "sha256-caxpESVH71mdrdihYvQZ9rTZPZqW0GyEG9un7MgpyRM=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "cfe1598d69a42a5edb204770e71b8df77efef2c3", + "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/grasp-audit/flake.nix b/grasp-audit/flake.nix new file mode 100644 index 0000000..c7a80ef --- /dev/null +++ b/grasp-audit/flake.nix @@ -0,0 +1,66 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + rust-overlay.url = "github:oxalica/rust-overlay"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { nixpkgs, rust-overlay, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { inherit system overlays; }; + manifest = pkgs.lib.importTOML ./Cargo.toml; + in with pkgs; { + devShells.default = mkShell { + nativeBuildInputs = [ + # Rust toolchain + rust-bin.stable.latest.default + + # Build tools + pkg-config + + # Development tools + gitlint + ]; + + buildInputs = [ + # Required dependencies + openssl + ]; + + shellHook = '' + echo "🦀 GRASP Audit development environment loaded" + echo "" + echo "Available commands:" + echo " cargo build - Build the project" + echo " cargo test - Run unit tests" + echo " cargo test --ignored - Run integration tests (needs relay)" + echo " cargo run --example simple_audit - Run example" + echo "" + echo "Rust version: $(rustc --version)" + echo "Cargo version: $(cargo --version)" + echo "" + echo "For RUST_SRC_PATH (rust-analyzer):" + export RUST_SRC_PATH=${pkgs.rustPlatform.rustLibSrc} + ''; + }; + + # Create package for the CLI binary + packages.default = pkgs.rustPlatform.buildRustPackage { + pname = manifest.package.name; + version = manifest.package.version; + src = ./.; + cargoLock = { + lockFile = ./Cargo.lock; + }; + buildInputs = [ + openssl + ]; + nativeBuildInputs = [ + pkg-config + ]; + doCheck = false; # Tests require a running Nostr relay + }; + }); +} diff --git a/grasp-audit/shell.nix b/grasp-audit/shell.nix deleted file mode 100644 index 54bb3b8..0000000 --- a/grasp-audit/shell.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ pkgs ? import {} }: - -pkgs.mkShell { - buildInputs = with pkgs; [ - # Rust toolchain - rustc - cargo - rustfmt - clippy - - # Build dependencies - gcc - pkg-config - - # Libraries - openssl - - # Development tools - git - ]; - - # Environment variables - RUST_BACKTRACE = "1"; - RUST_LOG = "info"; - - shellHook = '' - echo "🦀 Rust development environment loaded" - echo "" - echo "Available commands:" - echo " cargo build - Build the project" - echo " cargo test - Run unit tests" - echo " cargo test --ignored - Run integration tests (needs relay)" - echo " cargo run --example simple_audit - Run example" - echo "" - echo "Rust version: $(rustc --version)" - echo "Cargo version: $(cargo --version)" - ''; -} -- cgit v1.2.3