From df7c1f52924c1d708e7d7717e063812d62ef7f9f Mon Sep 17 00:00:00 2001 From: kiskaadee Date: Wed, 18 Nov 2026 14:52:12 -0500 Subject: [PATCH] chore(nixos): point deployments registry to ~/Workloads/deployments.yaml - Point HOMELAB_DEPLOYMENTS_FILE in nixos/modules/homeserver.nix to ${config.homelab.sitesDir}/deployments.yaml for both homelab-appctl and homelab-gitops - Replace config/deployments.yaml with an infrastructure-agnostic schemaVersion 1.0 example template (example-app, example-docs) and remove all personal workload entries - Sync AGENTS.md, README.md, docs/architecture.md, docs/gitops.md, docs/operations.md, and docs/decisions/README.md to reference ~/Workloads/deployments.yaml as the live registry and config/deployments.yaml as the template --- AGENTS.md | 2 +- README.md | 2 +- config/deployments.yaml | 54 ++++++++---------------------------- docs/architecture.md | 2 +- docs/decisions/README.md | 2 +- docs/gitops.md | 4 +-- docs/operations.md | 4 +-- nixos/modules/homeserver.nix | 3 +- 8 files changed, 22 insertions(+), 51 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 927415d..87dc2d2 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -67,7 +67,7 @@ docker compose config -q 1. **Workload Manifests (`app.yaml`)**: Describe declarative workload identity, routing metadata, and deployment intent only. Never introduce arbitrary command execution, host filesystem paths, privileged flags, or Docker control capabilities into `app.yaml`. 2. **GitOps Trust Boundary (`scripts/gitops_dispatcher.py`)**: - Webhook admission requires cryptographic authentication (HMAC-SHA256). - - Repository identity and filesystem paths must be resolved strictly through trusted Core configuration (`config/deployments.yaml`)—never directly from webhook payloads. + - Repository identity and filesystem paths must be resolved strictly through the trusted workloads registry (`~/Workloads/deployments.yaml` or `HOMELAB_DEPLOYMENTS_FILE`, templated by `config/deployments.yaml`)—never directly from webhook payloads. - Execution must remain allowlisted, serialized (`flock`), pre-validated by the Compose AST security checker, and free of shell interpolation (`shell=False`, no `eval`). 3. **Docker & Privilege Isolation**: - `socket-proxy` is the **only** service permitted to mount `/var/run/docker.sock` (strictly `:ro`, read-only API capabilities only; `POST=0`, `DELETE=0`, `BUILD=0`, `EXEC=0`). diff --git a/README.md b/README.md index 5c8f073..28d009c 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ For detailed runtime layers, network segmentation, and the P4 control-plane tran ├── flake.nix # NixOS host configuration, devShell (.venv symlink), and CI checks ├── docker-compose.yml # Core platform service stack ├── nixos/ # Declarative NixOS modules, systemd units, and SOPS secret wiring -├── config/ # Service configurations (Traefik, Authelia, Homepage, deployments.yaml) +├── config/ # Service configurations (Traefik, Authelia, Homepage, deployments.yaml template) ├── scripts/ │ ├── appctl # Thin operational CLI delegating to control plane daemon │ ├── appctl_daemon.py # Async HTTP/UDS daemon server (homelab-appctl.service) diff --git a/config/deployments.yaml b/config/deployments.yaml index 35b7016..00f921a 100644 --- a/config/deployments.yaml +++ b/config/deployments.yaml @@ -1,48 +1,18 @@ -# Core Authoritative Repository Identity Registry -# Governs admitted continuous deployment targets for GitOps webhook execution. +# Example Repository Identity Registry Template +# Live production deployments are configured in ~/Workloads/deployments.yaml +# (or overridden via the HOMELAB_DEPLOYMENTS_FILE environment variable). +# # Owns: repository identity, canonical filesystem path, and aliases. -# Enforces: strict path containment within ~/Workloads. +# Enforces: strict path containment within ~/Workloads (WORKLOADS_DIR). schemaVersion: "1.0" repositories: - snappymail: - path: "~/Workloads/snappymail" + example-app: + path: "~/Workloads/example-app" aliases: - - "homelab-snappymail" - - "mail" - - "webmail" - gitea: - path: "~/Workloads/homelab-gitea" + - "example" + - "homelab-example" + example-docs: + path: "~/Workloads/example-docs" aliases: - - "homelab-gitea" - - "git" - jellyfin: - path: "~/Workloads/homelab-jellyfin" - aliases: - - "homelab-jellyfin" - - "media" - courses: - path: "~/Workloads/courses" - aliases: - - "homelab-courses" - bdinvite: - path: "~/Workloads/homelab-bdinvite" - aliases: - - "homelab-bdinvite" - - "birthday" - landing: - path: "~/Workloads/homelab-landing" - aliases: - - "homelab-landing" - mermaid: - path: "~/Workloads/homelab-mermaid" - aliases: - - "homelab-mermaid" - excalidraw: - path: "~/Workloads/homelab-excalidraw" - aliases: - - "homelab-excalidraw" - houston: - path: "~/Workloads/homelab-houston" - aliases: - - "homelab-houston" + - "docs" diff --git a/docs/architecture.md b/docs/architecture.md index e60ea1c..438eb3a 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -52,7 +52,7 @@ The runtime environment consists of four functional layers: ### C. Cross-Cutting Orchestration Orchestration coordinates operations across the runtime layers: * **`appctl` Operational Control Plane Daemon (`homelab-appctl.service`, `scripts/appctl_daemon.py`, `scripts/appctl_router.py`)**: Centralized control plane running under isolated service identity `homelab-appctl:homelab-operators`. Exposes `POST /v1/operations` and `GET /v1/health` over `/run/homelab/appctl.sock` (mode `0660`) and `127.0.0.1:9001`, enforcing SHA-256 Bearer token authentication, 3-role RBAC (`homelab-admin`, `homelab-operator`, `homelab-viewer`), per-target `flock` serialization, fail-closed append-only audit logging (`/var/log/homelab/appctl/audit.jsonl`), Pydantic v2 `app.yaml` validation, Compose AST security checks, and pure-Python `.env` assembly. -* **GitOps Webhook Dispatcher (`scripts/gitops_dispatcher.py`)**: Governed by the `homelab-gitops.service` systemd unit, it receives webhooks on port 9000, verifies HMAC-SHA256 signatures, enforces the `config/deployments.yaml` allowlist, and delegates serialized `workload.update` execution to `homelab-appctl.service` over `/run/homelab/appctl.sock` using its `homelab-operator` Bearer token. +* **GitOps Webhook Dispatcher (`scripts/gitops_dispatcher.py`)**: Governed by the `homelab-gitops.service` systemd unit, it receives webhooks on port 9000, verifies HMAC-SHA256 signatures, enforces the `~/Workloads/deployments.yaml` allowlist (configured via `HOMELAB_DEPLOYMENTS_FILE`, with `config/deployments.yaml` as the example template), and delegates serialized `workload.update` execution to `homelab-appctl.service` over `/run/homelab/appctl.sock` using its `homelab-operator` Bearer token. --- diff --git a/docs/decisions/README.md b/docs/decisions/README.md index 4bc6ed3..a3b57b8 100644 --- a/docs/decisions/README.md +++ b/docs/decisions/README.md @@ -26,7 +26,7 @@ Repository-level architectural decisions are recorded in `docs/decisions/` using 1. **Tier 2 Rename (`~/Sites` -> `~/Workloads`)**: Canonical Tier 2 deployment root is `~/Workloads`, with `WORKLOADS_DIR` -> `SITES_DIR` environment fallback. 2. **Unified `canopy-workloads` Monorepo**: Tier 2 workload manifests (`app.yaml`, `docker-compose.yml`) consolidate under `~/Workloads//`, supporting hybrid per-app `.git` checkouts during migration. 3. **Mandatory State Isolation**: All mutable application data resides strictly under `~/var/lib/homelab//` (or named Docker volumes), never inside `~/Workloads`. - 4. **Core Registry & Safe Directory Containment**: `config/deployments.yaml` resolves admitted workloads within `WORKLOADS_DIR`; NixOS `safe.directory` includes `~/Workloads` and `~/Workloads/*`. + 4. **Workloads Registry & Safe Directory Containment**: `~/Workloads/deployments.yaml` (templated by `config/deployments.yaml`) resolves admitted workloads within `WORKLOADS_DIR`; NixOS `safe.directory` includes `~/Workloads` and `~/Workloads/*`. ### [ADR-0003: Centralized Runtime Validation & Serialization via Pydantic v2](0003-pydantic-v2-runtime-validation.md) * **Canonical Document**: [`0003-pydantic-v2-runtime-validation.md`](0003-pydantic-v2-runtime-validation.md) diff --git a/docs/gitops.md b/docs/gitops.md index ed30e70..4bf1c60 100644 --- a/docs/gitops.md +++ b/docs/gitops.md @@ -27,7 +27,7 @@ The GitOps engine is invoked via the `homelab-gitops.service` systemd unit runni ▼ ┌───────────────────────────────────────────────┐ │ 3. Authoritative Registry Resolution │ - │ Maps names via Core/config/deployments.yaml│ + │ Maps names via ~/Workloads/deployments.yaml│ │ Fails closed; zero dynamic discovery on host│ └───────────────────────┬───────────────────────┘ │ @@ -74,7 +74,7 @@ The GitOps engine is invoked via the `homelab-gitops.service` systemd unit runni ### C. Authoritative Repository Registry (`deployments.yaml`) * Webhook payloads identify targets strictly by logical name (e.g. `docs`, `homelab-docs`), never by raw filesystem path. -* `Core/config/deployments.yaml` is the **sole admission authority** for GitOps workloads. +* `~/Workloads/deployments.yaml` (configured via `HOMELAB_DEPLOYMENTS_FILE`, with `Core/config/deployments.yaml` serving as the example template) is the **sole admission authority** for GitOps workloads. * **No Dynamic Discovery**: Scanning `~/Sites` dynamically is strictly prohibited. An unapproved directory created on disk cannot receive webhook deployment rights merely by providing an `app.yaml`. * **Fail-Closed Guarantee**: If `deployments.yaml` is missing, unreadable, or malformed, the dispatcher fails closed and admits zero repositories. * **Input Validation**: Names must match `^[a-zA-Z0-9][a-zA-Z0-9._-]*$`. Slashes, backslashes, and path traversal sequences (`..`) are rejected. diff --git a/docs/operations.md b/docs/operations.md index 7fa71bd..48e22ac 100644 --- a/docs/operations.md +++ b/docs/operations.md @@ -163,12 +163,12 @@ Homelab enforces a strict architectural boundary between independent application #### 1. Independent Sites Workloads (`~/Sites/`) - **Automated Lifecycle**: Workloads declare their lifecycle via `app.yaml` manifests and Compose definitions. - **Update Command**: `appctl update ` performs pre-flight verification, branch matching, `git pull --ff-only`, container image pull, stack reload, and dashboard synchronization. -- **GitOps Webhook Dispatch**: Workloads registered in `config/deployments.yaml` can be triggered automatically via authenticated GitOps webhooks on Gitea push events. +- **GitOps Webhook Dispatch**: Workloads registered in `~/Workloads/deployments.yaml` (with `config/deployments.yaml` as the example template) can be triggered automatically via authenticated GitOps webhooks on Gitea push events. - **Daemon Permissions**: `homelab-appctl.service` holds read-write permissions over `~/Sites` to manage files, compose configurations, and workload state. #### 2. Homelab Core Platform Stack (`~/Core`) - **Host Foundation & Invariant Boundary**: Core defines NixOS host definitions, platform secrets, edge ingress, and security sandboxes. -- **No Untrusted Webhooks**: Core does **not** register for webhook dispatch in `config/deployments.yaml`. External push events can never trigger an automated deployment or rebuild of Core. +- **No Untrusted Webhooks**: Core does **not** register for webhook dispatch in `~/Workloads/deployments.yaml`. External push events can never trigger an automated deployment or rebuild of Core. - **Read-Only Sandbox**: Under NixOS systemd sandboxing (`ProtectHome = "read-only"`), `homelab-appctl.service` has strictly read-only access to `/home/operator/Core`. The daemon cannot mutate the Core Git repository or run `git pull` on Core. - **Operator-Driven Update Workflow**: Core updates must be executed explicitly by the operator: 1. Review and pull repository changes: diff --git a/nixos/modules/homeserver.nix b/nixos/modules/homeserver.nix index a619586..0f798d8 100644 --- a/nixos/modules/homeserver.nix +++ b/nixos/modules/homeserver.nix @@ -138,6 +138,7 @@ HOMELAB_STATE_ROOT = "/home/${config.homelab.operatorUser}/var/lib/homelab"; WORKLOADS_DIR = config.homelab.sitesDir; SITES_DIR = config.homelab.sitesDir; + HOMELAB_DEPLOYMENTS_FILE = "${config.homelab.sitesDir}/deployments.yaml"; }; serviceConfig = { @@ -217,7 +218,7 @@ CORE_DIR = config.homelab.coreDir; HOMELAB_STATE_ROOT = "/home/${config.homelab.operatorUser}/var/lib/homelab"; HOMELAB_CONFIG_DIR = "/home/${config.homelab.operatorUser}/.config/homelab"; - HOMELAB_DEPLOYMENTS_FILE = "${config.homelab.coreDir}/config/deployments.yaml"; + HOMELAB_DEPLOYMENTS_FILE = "${config.homelab.sitesDir}/deployments.yaml"; }; serviceConfig = {