No description
Find a file
Adriano Caloiaro e6224f526d
All checks were successful
test / hello (push) Successful in 1s
test: add test forgejo workflow
2026-07-19 09:19:48 -06:00
.age chore: rekey with gopass identity 2026-07-18 14:16:11 -06:00
.forgejo/workflows test: add test forgejo workflow 2026-07-19 09:19:48 -06:00
build chore: cleanup/add private network 2025-04-22 11:58:41 -06:00
deploy feat: add l4 proxy support to caddy 2026-07-18 14:16:11 -06:00
dns feat(forgejo): migrate from git.adriano.fyi -> code.adriano.fyi 2026-07-19 08:37:58 -06:00
docker feat: add l4 proxy support to caddy 2026-07-18 14:16:11 -06:00
jobs feat: add system-wide forgejo runner 2026-07-19 09:19:48 -06:00
operate chore: rekey with gopass identity 2026-07-18 14:16:11 -06:00
secrets chore: rekey with gopass identity 2026-07-18 14:16:11 -06:00
.env.age feat(b2): manage B2 buckets and scoped keys with Terraform 2026-07-18 14:16:10 -06:00
.envrc fix: duplicate load_age_dotenv in .envrc 2026-07-18 14:16:09 -06:00
.gitignore feat: count-based to generation-based refactor 2026-04-19 20:49:23 -06:00
.ignore feat: count-based to generation-based refactor 2026-04-19 20:49:23 -06:00
BLUE_GREEN_DEPLOYMENT.md chore: blue/green documentation updates 2026-07-18 14:16:10 -06:00
env.sample feat(b2): manage B2 buckets and scoped keys with Terraform 2026-07-18 14:16:10 -06:00
flake.lock feat(nixpkgs): bump 2026-07-09 09:24:40 -06:00
flake.nix feat: ncm-prepare refactor 2026-07-09 09:24:39 -06:00
LICENSE Initial commit 2025-04-12 14:56:42 -06:00
MIGRATION_GUIDE.md feat: support blue/green deploys 2026-04-19 20:49:22 -06:00
README.md Rekey secrets for green generation nodes 2026-04-19 20:49:23 -06:00
terraform.tfstate feat: tailscale initialization and nomad (almost clustered) 2025-04-15 16:53:01 -06:00

NCM

NCM is a NixOS-based infrastructure management toolbox for building, deploying, and operating cloud infrastructure with declarative configuration.

Overview

NCM provides an end-to-end workflow for managing cloud infrastructure:

  • Build custom NixOS images
  • Provision cloud resources
  • Configure and manage nodes
  • Deploy containerized workloads

Architecture

This project is organized around four independent modules:

Directory Purpose Technologies
build/ Build blessed NixOS images for deployment NixOS, nixos-generators
deploy/ Provision cloud infrastructure OpenTofu/Terraform, Linode
operate/ Configure and manage deployed nodes NixOS, Colmena, Tailscale
jobs/ Deploy workloads to the cluster Nomad, Terraform

Workflow

1. Build Images

Build custom NixOS images for your target platform:

cd build/
nix build .#linode    # Build Linode image
nix build .#qemu      # Build QEMU VM for testing

See build/README.md for details on building and uploading images.

2. Deploy Infrastructure

Provision cloud resources with OpenTofu:

cd deploy/
tofu init
tofu plan
tofu apply

See deploy/README.md for configuration details.

3. Prepare Node Configurations

After infrastructure is provisioned, prepare NixOS configurations:

ncm-prepare  # Generates host configs in operate/hosts/

This script:

  • Creates per-host configuration directories
  • Sets up SSH keys and secrets
  • Configures networking and Tailscale
  • Updates the flake.nix with new hosts

4. Apply Node Configurations

Deploy NixOS configurations to all cluster nodes:

colmena apply --impure

See operate/README.md for details on node configuration.

5. Deploy Workloads

Deploy applications and services to the Nomad cluster:

cd jobs/
tofu init
tofu plan
tofu apply

See jobs/README.md for available job specifications.

Quick Start

  1. Prerequisites: Ensure you have Nix with flakes enabled
  2. Enter development environment: nix develop (or use direnv)
  3. View available commands: The shell will show available helper scripts
  4. Configure environment: Copy .env.sample and fill in required values
  5. Follow the workflow outlined above

Blue/Green Deployments

NCM supports zero-downtime cluster updates through blue/green deployments. Add new nodes alongside existing ones, migrate workloads, then remove old nodes.

See BLUE_GREEN_DEPLOYMENT.md for the complete guide.

Quick example:

# 1. Add new nodes to deploy/compute_providers/linode/nodes.tf
# 2. Deploy infrastructure
cd deploy/ && tofu apply

# 3. Configure new nodes only
ncm-add-nodes

# 4. Deploy NixOS to new nodes
colmena apply --on ncm-3,ncm-4,ncm-5 --impure

# 5. Drain old nodes
nomad node drain -enable -yes ncm-0

# 6. Remove old nodes from nodes.tf and destroy
cd deploy/ && tofu apply

Environment Variables

Required environment variables are documented in .env.sample. Use the ess tool (env-sample-sync) to keep them synchronized.

Documentation

Each module has detailed documentation:

Technologies

  • NixOS: Declarative Linux distribution
  • OpenTofu: Infrastructure as Code
  • Colmena: NixOS deployment tool
  • Nomad: Workload orchestration
  • Tailscale: Zero-config VPN
  • agenix-rekey: Automated age-based secrets management