This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a NixOS fleet management repository using Colmena for deploying and managing multiple servers. The architecture follows a modular design:
- flake.nix: Main entry point defining inputs, development shell, and Colmena hive configuration
- hosts.nix: Single source of truth for all host definitions (IPs, users, tags, descriptions)
- hosts/: Individual host configurations importing from common.nix and modules
- modules/: Reusable NixOS modules organized by functionality
The fleet uses a custom module system under the fleet.* namespace:
fleet.monitoring.*: Prometheus, Grafana, Node Exporterfleet.dev.*: Jenkins, Giteafleet.networking.*: Reverse proxy with TLSfleet.security.*: Self-signed CA management
All hosts share common configuration via hosts/common.nix which includes SSH keys, user management, basic security, and Node Exporter. Individual hosts import specific modules based on their role.
# Enter development shell with Colmena tools
nix develop# Build all hosts
colmena build
# Deploy to all hosts
colmena apply
# Deploy to specific host
colmena apply --on hostname
# Deploy to hosts with specific tag
colmena apply --on @tag-name
# Execute command on host
colmena exec --on hostname -- command
# Execute command on all hosts
colmena exec -- commandWhen adding new modules:
- Create under
modules/following the existing structure - Use the
fleet.*namespace for options - Follow the pattern: options definition, implementation with
mkIf cfg.enable - Import in relevant host configurations
To add a new host:
- Add entry to
hosts.nixwith IP, user, tags, description - Create
hosts/hostname/directory withconfiguration.nixandhardware-configuration.nix - Add to
colmenaHiveinflake.nix
flake.nix:19: Host definitions imported from hosts.nixflake.nix:45-96: Colmena hive configuration with deployment settingshosts/common.nix:81: Fleet monitoring enablementmodules/monitoring/prometheus.nix:32-36: Node exporter targets configuration