- Update docs/appctl.md to cover core_manifest.py, Schema v1.0, Class A/B source provenance, and two-axis status output. - Align docs/architecture.md, docs/secrets-and-state.md, and docs/operations.md with P1 mail topology (Stalwart on smtp.<domain>, SnappyMail in ~/Sites, workload state under ~/var/lib/homelab/<app>/). - Remove external vault path references from docs/decisions/README.md and scrub remaining personal domains/usernames across docs/ and SECURITY.md. - Extend platform genericism security invariant test to guard docs/ and root markdown/flake files.
4.8 KiB
4.8 KiB
🚀 Homelab Core — Setup & Provisioning Guide
This document describes procedures for provisioning a host machine, bootstrapping Homelab Core, and onboarding new application workloads into ~/Sites.
1. Host Provisioning & Bootstrapping
A. Fresh Machine Provisioning via NixOS Install
When provisioning bare-metal hardware or a virtual machine from a NixOS Minimal ISO:
- Partition and format disks according to
nixos/hardware-configuration.nix(e.g. boot EFI partition and root filesystem). - Mount partitions under
/mnt. - Restore Host Secrets Key: Copy the host SSH private key to
/mnt/etc/ssh/ssh_host_ed25519_key(mode0600). This is required becausesops-nixdecryptsnixos/secrets.yamlduring system activation. - Clone the Core repository to
/mnt/home/<operator>/Core. - Run the NixOS installer:
nixos-install --flake /mnt/home/<operator>/Core#server reboot
2. Platform Bootstrap on a Running Host
When initializing the platform on an installed system:
Step 1: Verify Host Secrets Key
Ensure the host SSH key exists with strict permissions:
sudo ls -l /etc/ssh/ssh_host_ed25519_key
sudo chmod 600 /etc/ssh/ssh_host_ed25519_key
Step 2: Apply Declarative NixOS Configuration
cd ~/Core
sudo nixos-rebuild switch --flake ~/Core#server
This configures:
- Docker daemon, host firewall rules, and system packages.
- Decrypted secret files in
/run/secrets/homeserver.envand/run/secrets/traefik-deployments.env. - Systemd service units (
homeserver-core,homelab-gitops,dynu-monitor).
Step 3: Create External Docker Networks
The Core Compose stack and workloads require the proxy-net and socket-net bridge networks:
docker network create proxy-net 2>/dev/null || true
docker network create socket-net 2>/dev/null || true
Step 4: Start Platform Services
sudo systemctl start homeserver-core
Check running containers:
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
Step 5: Verify DNS & Certificates
- Trigger an immediate DDNS update:
sudo systemctl start dynu-monitor - Verify Let's Encrypt wildcard certificate generation:
appctl ssl traefik
Step 6: Initialize LLDAP Directory
- Navigate to
https://users.${HOMELAB_DOMAIN}(e.g.,https://users.example.com). - Authenticate using
adminand the password configured innixos/secrets.yaml(lldap/admin_password). - Create standard user accounts and assign them to required groups.
3. Onboarding a New Application Workload
Applications live in isolated repositories under ~/Sites/. To deploy a new service:
Step 1: Create Repository Directory
mkdir -p ~/Sites/homelab-myapp
cd ~/Sites/homelab-myapp
git init
Step 2: Create app.yaml Manifest
Create ~/Sites/homelab-myapp/app.yaml:
schema_version: "1.0"
name: "myapp"
aliases:
- "app"
domain: "myapp.example.com"
description: "My New Application Service"
visible: true
auth: false
networks:
- proxy-net
env:
APP_PORT: "8080"
deployment:
branch: "main"
strategy: "compose"
actions:
- git_pull
- compose_up
homepage:
title: "My App"
group: "Applications"
icon: "default.png"
container: "myapp"
weight: 50
Step 3: Create docker-compose.yml
Create ~/Sites/homelab-myapp/docker-compose.yml:
services:
myapp:
image: myapp/image:latest
container_name: ${CONTAINER_NAME:-myapp}
restart: always
environment:
- PORT=${APP_PORT:-8080}
networks:
- proxy-net
labels:
- "traefik.enable=true"
# HTTPS Router
- "traefik.http.routers.${CONTAINER_NAME:-myapp}.rule=Host(`${SERVICE_DOMAIN}`)"
- "traefik.http.routers.${CONTAINER_NAME:-myapp}.entrypoints=websecure"
- "traefik.http.routers.${CONTAINER_NAME:-myapp}.tls=true"
- "traefik.http.routers.${CONTAINER_NAME:-myapp}.service=${CONTAINER_NAME:-myapp}-svc"
# HTTP -> HTTPS Redirect
- "traefik.http.routers.${CONTAINER_NAME:-myapp}-red.rule=Host(`${SERVICE_DOMAIN}`)"
- "traefik.http.routers.${CONTAINER_NAME:-myapp}-red.entrypoints=web"
- "traefik.http.routers.${CONTAINER_NAME:-myapp}-red.middlewares=https-redirect@docker"
# Target Port
- "traefik.http.services.${CONTAINER_NAME:-myapp}-svc.loadbalancer.server.port=${APP_PORT:-8080}"
networks:
proxy-net:
name: ${PROXY_NETWORK:-proxy-net}
external: true
Step 4: Launch and Sync
# Launch application stack via appctl
appctl up myapp
# Inspect application diagnostics
appctl info myapp
4. Verification
Before committing changes to Homelab Core, run the repository test runner:
cd ~/Core
./scripts/test
This runs:
- Code formatting and lint checks (
ruff). - Security and structural invariant tests (
pytest tests/). - Nix flake check (
nix flake check).