Files
ngit-grasp/flake.nix
T
DanConwayDev 90bd544915 build(workspace): unify grasp-audit into single workspace
grasp-audit had its own Cargo.lock and flake.nix while also being declared
a member of the root workspace. This dual model let the lockfiles drift:
the root resolved nostr-sdk 0.45.0-alpha.1 while grasp-audit's own lock was
stale at 0.43.0, despite both declaring the same version.

Collapse to a true single workspace:
- Remove grasp-audit/{Cargo.lock,flake.nix,flake.lock}; the root Cargo.lock
  and flake now cover both crates.
- Root flake exposes packages.ngit-grasp and packages.grasp-audit (built via
  cargo -p), with packages.default = ngit-grasp. Single dev shell gains
  gitlint.
- Drop the redundant grasp-audit/target/ (cargo resolves to the root target).
- Update .gitignore, AGENTS.md, README.md, and test-ngit-relay.sh comment to
  describe the single-workspace model (cargo build -p grasp-audit, no cd).

The coupling stays one-directional (ngit-grasp dev-deps use grasp-audit; the
reverse never existed), keeping the door open to split grasp-audit out later.
Not published to crates.io.

Verified: cargo build --workspace, cargo test -p {ngit-grasp,grasp-audit}
--lib (440 + 36 pass), nix build .#ngit-grasp and .#grasp-audit.
2026-06-16 14:50:34 +00:00

87 lines
3.0 KiB
Nix

{
description = "ngit-grasp - A GRASP implementation in Rust";
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" "rust-analyzer" ];
};
in {
devShells.default = pkgs.mkShell {
# Single dev shell for the whole workspace (ngit-grasp + grasp-audit).
buildInputs = with pkgs; [ rustToolchain pkg-config openssl git gitlint ];
RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library";
shellHook = ''
echo "🚀 ngit-grasp workspace development environment"
echo "Rust version: $(rustc --version)"
echo ""
echo "Quick commands:"
echo " cargo build - Build the whole workspace"
echo " cargo test - Run ngit-grasp tests"
echo " cargo run - Run the relay"
echo " cargo build -p grasp-audit - Build the audit tool"
echo " cargo test -p grasp-audit - Run grasp-audit unit tests"
echo ""
'';
};
# Both crates are members of a single workspace sharing one Cargo.lock.
packages.default = self.packages.${system}.ngit-grasp;
packages.ngit-grasp = pkgs.rustPlatform.buildRustPackage {
pname = "ngit-grasp";
version = "1.1.0";
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
};
# Only build/test the ngit-grasp package, not the whole workspace.
cargoBuildFlags = [ "-p" "ngit-grasp" ];
nativeBuildInputs = with pkgs; [ pkg-config git ];
buildInputs = with pkgs; [ openssl ];
# Run lib tests only; integration tests spawn a live relay and require
# network access not available in the Nix sandbox.
doCheck = true;
cargoTestFlags = [ "-p" "ngit-grasp" "--lib" ];
};
packages.grasp-audit = pkgs.rustPlatform.buildRustPackage {
pname = "grasp-audit";
version = "0.1.0";
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
};
cargoBuildFlags = [ "-p" "grasp-audit" ];
nativeBuildInputs = with pkgs; [ pkg-config git ];
buildInputs = with pkgs; [ openssl ];
# Audit tests require a running Nostr relay; skip in the sandbox.
doCheck = false;
};
})) // {
# NixOS module for deployment
nixosModules.default = import ./nix/module.nix;
nixosModules.ngit-grasp = self.nixosModules.default;
};
}