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
This commit is contained in:
kiskaadee committed 2026-09-11 19:50:18 -05:00
1 parent 9f71b32db9
commit 945e80206f
3 files changed
+70 -42

No files matched your search

+38 -11
View File
@@ -45,17 +45,17 @@ User and service applications (e.g. `dashboard`, `docs`, `jellyfin`, `excalidraw
The security model is built on zero hardcoded secrets and defense-in-depth: The security model is built on zero hardcoded secrets and defense-in-depth:
``` ```text
[~/Config/hosts/desktop/secrets.yaml] (Encrypted with SOPS + age keys) [nixos/secrets.yaml] (Encrypted with SOPS + age keys)
│ │
▼ (Decrypted at boot by sops-nix using SSH host key) ▼ (Decrypted at boot by sops-nix using host SSH key)
[/run/secrets/rendered/homeserver.env] & [/run/secrets/rendered/traefik-deployments.env] [/run/secrets/rendered/homeserver.env] & [/run/secrets/rendered/traefik-deployments.env]
│ │
▼ (Fed via --env-file and appctl) ▼ (Fed via --env-file and appctl)
[Core & Sites Containers] [Core & Sites Containers]
``` ```
1. **SOPS & sops-nix Integration:** All sensitive tokens (Dynu API key, Authelia session secrets, JWT keys, database passwords) are encrypted in `~/Config/hosts/desktop/secrets.yaml` and decrypted by NixOS at runtime into in-memory `/run/secrets/rendered/`. 1. **SOPS & sops-nix Integration:** All sensitive tokens (Dynu API key, Authelia session secrets, JWT keys, database passwords) are encrypted in `nixos/secrets.yaml` and decrypted by NixOS at runtime into in-memory `/run/secrets/` and `/run/secrets/rendered/`.
2. **Edge TLS & HSTS:** All external traffic is forced over HTTPS using Let's Encrypt wildcard certificates with strict redirect schemes (`https-redirect@docker`). 2. **Edge TLS & HSTS:** All external traffic is forced over HTTPS using Let's Encrypt wildcard certificates with strict redirect schemes (`https-redirect@docker`).
3. **Authelia ForwardAuth:** Applications that require authentication declare `traefik.http.routers.<name>.middlewares=authelia-auth@docker`, delegating identity verification to Authelia. 3. **Authelia ForwardAuth:** Applications that require authentication declare `traefik.http.routers.<name>.middlewares=authelia-auth@docker`, delegating identity verification to Authelia.
4. **Socket Isolation:** Direct Docker daemon sockets are completely hidden behind `socket-proxy`. 4. **Socket Isolation:** Direct Docker daemon sockets are completely hidden behind `socket-proxy`.
@@ -170,15 +170,42 @@ appctl up myapp
--- ---
## ⚙️ NixOS Service Management ## ❄️ Declarative NixOS Appliance
The Core Control Plane runs as a native systemd unit managed declaratively by NixOS: This repository is a self-contained NixOS appliance. It defines the operating system, Docker infrastructure, firewall rules, automated DDNS updates, and host shell environment in a single flake.
* **Service Unit:** `homeserver-core.service` ### Repository NixOS Layout:
* **Nix Module:** [`~/Config/hosts/desktop/homeserver.nix`](file:///home/kiskaadee/Config/hosts/desktop/homeserver.nix) * **[`flake.nix`](flake.nix)** — Flake entrypoint defining `nixosConfigurations.server`.
* **Status Inspection:** `systemctl status homeserver-core` * **[`nixos/configuration.nix`](nixos/configuration.nix)** — Standalone headless host configuration (locale, SSH, Docker, packages).
* **Logs:** `journalctl -u homeserver-core -f` * **[`nixos/hardware-configuration.nix`](nixos/hardware-configuration.nix)** — Server hardware, disk mounts, and kernel parameters.
* **Restart:** `sudo systemctl restart homeserver-core` * **[`nixos/secrets.yaml`](nixos/secrets.yaml)** — SOPS-encrypted secrets for the server.
* **[`nixos/modules/homeserver.nix`](nixos/modules/homeserver.nix)** — `homeserver-core.service`, `homelab-gitops.service`, and Authelia secrets.
* **[`nixos/modules/traefik-deployments.nix`](nixos/modules/traefik-deployments.nix)** — Traefik applications environment secrets (`traefik-deployments.env`).
* **[`nixos/modules/dynu.nix`](nixos/modules/dynu.nix)** — Dynu DDNS smart IP monitor timer and ddclient credentials.
* **[`nixos/modules/shell.nix`](nixos/modules/shell.nix)** — Server-tailored bash shell profile, aliases, and utilities.
### Common Operations:
```bash
# Rebuild and switch the running system
sudo nixos-rebuild switch --flake ~/Core#server
# (or use the built-in alias: nix-switch)
# Inspect core service units
systemctl status homeserver-core
journalctl -u homeserver-core -f
# Inspect GitOps webhook dispatcher
systemctl status homelab-gitops
# Inspect dynamic IP monitor
systemctl status dynu-monitor
```
### Disaster Recovery:
Any clean machine can be provisioned into this server:
```bash
nixos-install --flake ~/Core#server
```
--- ---
+2 -2
View File
@@ -29,8 +29,8 @@ The most critical security feature. No container (including Traefik or Portainer
Despite the hardening, you should remain vigilant about the following: Despite the hardening, you should remain vigilant about the following:
### 1. Host-Level Security (The Foundation) ### 1. Host-Level Security (The Foundation)
If an attacker gains SSH access to your Arch Linux host, they have total control. If an attacker gains SSH access to your host, they have control over the system.
- **Action**: Use SSH Keys only (disable password login). Install `fail2ban`. Keep the host kernel updated (`pacman -Syu`). - **Action**: Use SSH Keys exclusively (`PermitRootLogin = "no"` is enforced by NixOS). Keep your Nix flake inputs and system updated (`sudo nixos-rebuild switch --flake ~/Core#server`).
### 2. Application-Specific Vulnerabilities ### 2. Application-Specific Vulnerabilities
A zero-day exploit in Gitea or Ollama could allow an attacker to execute code *inside* that specific container. A zero-day exploit in Gitea or Ollama could allow an attacker to execute code *inside* that specific container.
+30 -29
View File
@@ -22,8 +22,8 @@ All sensitive tokens, encryption keys, and credentials are encrypted using **`so
### Secrets Lifecycle: ### Secrets Lifecycle:
``` ```text
[~/Config/hosts/desktop/secrets.yaml] (Encrypted with Age) [nixos/secrets.yaml] (Encrypted with Age)
│ │
▼ (Decrypted at boot by sops-nix daemon) ▼ (Decrypted at boot by sops-nix daemon)
1. [/run/secrets/rendered/homeserver.env] --> Fed to Core Compose Stack 1. [/run/secrets/rendered/homeserver.env] --> Fed to Core Compose Stack
@@ -39,55 +39,56 @@ All sensitive tokens, encryption keys, and credentials are encrypted using **`so
To update credentials (e.g. changing your Dynu API key or updating Authelia user passwords): To update credentials (e.g. changing your Dynu API key or updating Authelia user passwords):
1. Navigate to your NixOS configuration repository: 1. Navigate to the core repository:
```bash ```bash
cd ~/Config cd ~/Core
``` ```
2. Decrypt and open the secrets file in your editor: 2. Decrypt and open the secrets file in your editor:
```bash ```bash
nix-shell -p sops --run "sops hosts/desktop/secrets.yaml" sops nixos/secrets.yaml
``` ```
3. Update or append keys under the root block: 3. Update or append keys under the root block:
```yaml ```yaml
dynu_api_key: "your_dynu_api_key" dynu:
acme_email: "your_email@domain.com" api_key: "your_dynu_api_key"
authelia_session_secret: "secure_64_char_secret" traefik:
authelia_storage_encryption_key: "secure_64_char_key" acme_email: "your_email@domain.com"
authelia_identity_validation_reset_password_jwt_secret: "secure_64_char_jwt_secret" authelia:
authelia_user_kiskaadee_password_hash: "$argon2id$v=19$m=65536..." 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:* *To generate an Argon2 password hash securely, run:*
```bash ```bash
docker run --rm -it authelia/authelia:latest authelia crypto hash generate argon2 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. 4. Save and close. SOPS will automatically encrypt the modified file before saving.
5. Rebuild the system to apply new secret templates:
```bash
sudo nixos-rebuild switch --flake ~/Core#server
```
--- ---
## ⚙️ Declarative NixOS Modules ## ⚙️ Declarative NixOS Modules
The Core stack and deployment environments are defined declaratively in `~/Config`: The Core stack and deployment environments are defined declaratively in `nixos/modules/`:
### 1. Control Plane Module ([`hosts/desktop/homeserver.nix`](file:///home/kiskaadee/Config/hosts/desktop/homeserver.nix)) ### 1. Control Plane Module ([`nixos/modules/homeserver.nix`](../nixos/modules/homeserver.nix))
Generates `/run/secrets/rendered/homeserver.env` and manages the `homeserver-core.service` systemd daemon: Generates `/run/secrets/rendered/homeserver.env`, `/run/secrets/rendered/users.yml`, and manages the `homeserver-core.service` and `homelab-gitops.service` systemd daemons.
```nix
sops.templates."homeserver.env" = {
owner = "kiskaadee";
content = lib.generators.toKeyValue {} {
DOMAIN = "roadtotech.me";
DOCKER_API_VERSION = "1.40";
DYNU_API_KEY = config.sops.placeholder.dynu_api_key;
ACME_EMAIL = config.sops.placeholder.acme_email;
AUTHELIA_SESSION_SECRET = config.sops.placeholder.authelia_session_secret;
AUTHELIA_STORAGE_ENCRYPTION_KEY = config.sops.placeholder.authelia_storage_encryption_key;
AUTHELIA_IDENTITY_VALIDATION_RESET_PASSWORD_JWT_SECRET = config.sops.placeholder.authelia_identity_validation_reset_password_jwt_secret;
};
};
```
### 2. Applications Secret Module ([`hosts/desktop/traefik-deployments.nix`](file:///home/kiskaadee/Config/hosts/desktop/traefik-deployments.nix)) ### 2. Applications Secret Module ([`nixos/modules/traefik-deployments.nix`](../nixos/modules/traefik-deployments.nix))
Generates `/run/secrets/rendered/traefik-deployments.env` consumed by `appctl`. Generates `/run/secrets/rendered/traefik-deployments.env` consumed by `appctl`.
### 3. Dynamic DNS Module ([`nixos/modules/dynu.nix`](../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`](../nixos/modules/shell.nix))
Defines interactive bash aliases, git helpers, and terminal tools via system `/etc/bashrc`.
--- ---
## 🚀 Running and Managing the Stack ## 🚀 Running and Managing the Stack