Skip to content

Instantly share code, notes, and snippets.

@batonac
Created January 7, 2026 20:22
Show Gist options
  • Select an option

  • Save batonac/7e0eb5758834f14b34fbb05f1d1d0c08 to your computer and use it in GitHub Desktop.

Select an option

Save batonac/7e0eb5758834f14b34fbb05f1d1d0c08 to your computer and use it in GitHub Desktop.
CAI Standalone Flake
{
description = "CAI Development Environment - Nix Flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs-python = {
url = "github:cachix/nixpkgs-python";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
devenv.url = "github:cachix/devenv";
# CAI source - can point to upstream or local
cai-src = {
url = "github:aliasrobotics/cai";
flake = false; # It's not a flake, just source code
};
};
outputs = { self, nixpkgs, flake-utils, devenv, cai-src, ... } @ inputs:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
in
{
devShells.default = devenv.lib.mkShell {
inherit inputs pkgs;
modules = [
{
# Use CAI source directory
env.CAI_SRC = "${cai-src}";
# Package list
packages = with pkgs; [
# System dependencies
git
curl
wget
gnupg
openssh
# Build tools
gcc
cmake
pkg-config
rustc
cargo
gfortran
# Linux kernel headers (for evdev/pynput)
linuxHeaders
# Libraries
hdf5
openblas
# Security and pentesting tools
nmap
netcat-gnu
dirb
gobuster
nikto
sqlmap
john
hashcat
# hydra # Temporarily disabled due to build issues
wireshark-cli
tcpdump
binutils
metasploit
seclists
wordlists
whatweb
# Network utilities
dnsutils
iputils
nettools
sshpass
# Documentation and output
asciinema
graphviz
# Container tools (optional)
docker-client
# Development tools
cloc
# Go (for some security tools)
go
];
# Environment variables
env = {
PROMPT_TOOLKIT_NO_CPR = "1";
CAI_STREAM = "false";
CAI_MODEL = "alias1";
};
# Scripts
scripts = {
cai-dev.exec = ''
echo "πŸ€– CAI Development Environment Ready!"
echo ""
echo "Available commands:"
echo " cai - Run CAI"
echo " make sync - Sync dependencies with uv"
echo " make format - Format code with ruff"
echo " make lint - Lint code with ruff"
echo " make tests - Run tests"
echo " make coverage - Run tests with coverage"
echo " make build-docs - Build documentation"
echo " make serve-docs - Serve documentation locally"
echo ""
echo "Environment:"
echo " Python: $(python --version)"
echo " uv: $(uv --version)"
echo " Nmap: $(nmap --version | head -n1)"
echo " Metasploit: $(msfconsole --version 2>/dev/null || echo 'Not available')"
echo ""
echo "CAI Source: $CAI_SRC"
echo "Dependencies managed by devenv + uv from uv.lock"
'';
cai-setup.exec = ''
echo "Setting up CAI development environment..."
# Create .env if it doesn't exist
if [ ! -f .env ]; then
echo "Creating .env from .env.example..."
if [ -f "$CAI_SRC/.env.example" ]; then
cp "$CAI_SRC/.env.example" .env
echo "βœ“ .env file created. Please update with your API keys."
else
echo "⚠️ .env.example not found in CAI source"
fi
fi
echo ""
echo "βœ“ Setup complete!"
echo " Dependencies are automatically synced by devenv + uv"
echo " Run 'cai' to start using the framework"
'';
};
# Shell hooks
enterShell = ''
# Create logs directory if it doesn't exist
mkdir -p logs
# Display welcome message
cat << 'EOF'
╔════════════════════════════════════════════════════════════╗
β•‘ β•‘
β•‘ πŸ€– CAI - Cybersecurity AI Framework β•‘
β•‘ β•‘
β•‘ Development Environment (Nix + devenv + uv) β•‘
β•‘ β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
EOF
echo ""
echo "Quick start:"
echo " cai-setup - First time setup"
echo " cai-dev - Show available commands and info"
echo ""
echo "CAI Source: $CAI_SRC"
echo "Dependencies auto-synced by devenv from uv.lock"
echo ""
# Check if .env exists
if [ ! -f .env ]; then
echo "⚠️ No .env file found. Run 'cai-setup' or copy .env.example to .env"
echo ""
fi
'';
# Languages - use devenv's native Python + uv support
# Point to CAI source for pyproject.toml and uv.lock
languages = {
python = {
enable = true;
version = "3.11";
uv = {
enable = true;
sync = {
enable = true;
allExtras = true;
allPackages = true;
groups = [ "dev" ];
};
};
};
};
# Processes (optional - for running services)
# processes = {
# metasploit-rpc.exec = "msfrpcd -P cai";
# };
# Git hooks (renamed from pre-commit in devenv2)
git-hooks.hooks = {
ruff-format = {
enable = true;
name = "ruff format";
entry = "${pkgs.python311Packages.ruff}/bin/ruff format";
language = "system";
types = [ "python" ];
};
ruff-check = {
enable = true;
name = "ruff check";
entry = "${pkgs.python311Packages.ruff}/bin/ruff check";
language = "system";
types = [ "python" ];
};
};
# Dotenv integration
dotenv.enable = true;
}
];
};
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment