Files
nixos-core/docs/setup_guide.md
T
kiskaadee 945e80206f docs: update documentation for standalone NixOS appliance
- README.md: update secrets architecture to nixos/secrets.yaml and add Declarative NixOS Appliance section
- docs/setup_guide.md: update SOPS secrets workflow and module paths to nixos/
- SECURITY.md: update host-level security recommendations for NixOS
2026-09-11 19:50:18 -05:00

4.1 KiB

Setup & Secrets Management Guide (Traefik Homelab)

This document provides an exhaustive operational guide for configuring, deploying, securing, and maintaining the Traefik Homelab Core Control Plane on NixOS.


🏗️ Architectural Overview

The core infrastructure runs as a consolidated Docker Compose stack in /home/kiskaadee/Core:

  • docker-compose.yml: Root compose specification defining all control plane services (traefik, authelia, portainer, dozzle, watchtower, diun, socket-proxy).
  • config/: Persistent state directories:
    • config/letsencrypt/: Contains SSL certificate storage (acme.json).
    • config/authelia/: Contains configuration (configuration.yml, users.yml) and authentication database (db.sqlite3).
    • config/diun/: Diun container update tracking database (diun.db).

🔒 Secrets Architecture & SOPS Flow

All sensitive tokens, encryption keys, and credentials are encrypted using sops-nix (Mozilla SOPS with age keys derived from the host SSH key). No plaintext secrets exist in any git repository.

Secrets Lifecycle:

[nixos/secrets.yaml] (Encrypted with Age)
       │
       ▼ (Decrypted at boot by sops-nix daemon)
1. [/run/secrets/rendered/homeserver.env]          --> Fed to Core Compose Stack
2. [/run/secrets/rendered/traefik-deployments.env] --> Fed to appctl & App Stacks
       │
       ▼
[Active Docker Containers]

🔑 Modifying and Adding Secrets

To update credentials (e.g. changing your Dynu API key or updating Authelia user passwords):

  1. Navigate to the core repository:
    cd ~/Core
    
  2. Decrypt and open the secrets file in your editor:
    sops nixos/secrets.yaml
    
  3. Update or append keys under the root block:
    dynu:
      api_key: "your_dynu_api_key"
    traefik:
      acme_email: "your_email@domain.com"
    authelia:
      session_secret: "secure_64_char_secret"
      storage_encryption_key: "secure_64_char_key"
      jwt_secret: "secure_64_char_jwt_secret"
      users:
        kiskaadee:
          password_hash: "$argon2id$v=19$m=65536..."
    
    To generate an Argon2 password hash securely, run:
    docker run --rm -it authelia/authelia:latest authelia crypto hash generate argon2
    
  4. Save and close. SOPS will automatically encrypt the modified file before saving.
  5. Rebuild the system to apply new secret templates:
    sudo nixos-rebuild switch --flake ~/Core#server
    

⚙️ Declarative NixOS Modules

The Core stack and deployment environments are defined declaratively in nixos/modules/:

1. Control Plane Module (nixos/modules/homeserver.nix)

Generates /run/secrets/rendered/homeserver.env, /run/secrets/rendered/users.yml, and manages the homeserver-core.service and homelab-gitops.service systemd daemons.

2. Applications Secret Module (nixos/modules/traefik-deployments.nix)

Generates /run/secrets/rendered/traefik-deployments.env consumed by appctl.

3. Dynamic DNS Module (nixos/modules/dynu.nix)

Configures the smart IP monitor timer and updates ddclient when IP rotations occur.

4. Server Shell Module (nixos/modules/shell.nix)

Defines interactive bash aliases, git helpers, and terminal tools via system /etc/bashrc.


🚀 Running and Managing the Stack

Standard Systemd Operations:

  • Start: sudo systemctl start homeserver-core
  • Stop: sudo systemctl stop homeserver-core
  • Restart: sudo systemctl restart homeserver-core
  • Status: systemctl status homeserver-core
  • Live Logs: journalctl -u homeserver-core -f

Dynamic Tweaks without Rebuilding NixOS:

When making configuration adjustments to docker-compose.yml (e.g. tuning Traefik middlewares):

cd ~/Core
docker compose --env-file /run/secrets/rendered/homeserver.env up -d --remove-orphans