Files
nixos-config/docs/secrets-management.md
T
kiskaadee 7c5e14c905 refactor: decouple sops-nix from workstation, update documentation, and clean up scripts
- Remove `sops-nix` input and integration modules from `flake.nix` and `flake.lock`.
- Transition secrets management documentation (`docs/secrets-management.md`, `docs/package-and-secrets.md`) to reflect the workstation's role as an operator management station targeting the decoupled Core repository.
- Remove obsolete `$HOME/Core/scripts` from user `sessionPath` in `home/default.nix` and `home/shell.nix`.
- Clean up Hyprland code paths in the Niri-native `record.sh` utility.
- Refine DMS options in `system/desktop.nix`.
2026-09-13 01:17:15 -05:00

3.4 KiB

🔒 Homelab & Workstation Secrets Management

This document describes the GitOps secrets management workflow using Mozilla SOPS and age.


🏛️ Architectural Model: Author vs Consumer

Secrets management follows a strict separation between authoring (human operator on the workstation) and runtime consumption (headless server):

┌─────────────────────────────────────────────────────────┐
│ WORKSTATION (Author / Operator)                         │
│ - Key: ~/.config/sops/age/keys.txt (&laptop)            │
│ - Tooling: sops, age, rbw (installed in home/dev.nix)   │
│ - Action: Decrypt, edit, and re-encrypt secrets locally │
└───────────────────────────┬─────────────────────────────┘
                            │
              Git Commit (Ciphertext in repo)
                            │
                            ▼
┌─────────────────────────────────────────────────────────┐
│ SERVER (Consumer / Runtime)                             │
│ - Key: /etc/ssh/ssh_host_ed25519_key (&server)          │
│ - Tooling: sops-nix systemd activation service (root)   │
│ - Action: Unattended decryption into RAM (/run/secrets) │
└─────────────────────────────────────────────────────────┘
  • Why editing secrets directly on the remote server fails: The server does not have the operator's age key. Its host SSH key is owned by root:root with 0600 permissions and is only read by sops-nix during systemd activation at boot.
  • Why the workstation is the author: The operator's private age key resides in ~/.config/sops/age/keys.txt on the laptop. This allows secure local editing without exposing administrative keys on production nodes.

🛠️ Managing Secrets for Core

Production homelab secrets are maintained in the Core repository at Core/nixos/secrets.yaml.

1. Edit Secrets Locally

From your laptop, open the encrypted secrets file:

sops ~/Projects/active/homelab/Core/nixos/secrets.yaml

SOPS reads your local ~/.config/sops/age/keys.txt, decrypts the file in $EDITOR, and automatically re-encrypts the ciphertext using the public recipient keys configured in Core/.sops.yaml:

  • *server (for server boot decryption)
  • *laptop (for operator editing)

2. Commit and Deploy

Commit the newly encrypted ciphertext and push to your git remote:

cd ~/Projects/active/homelab/Core
git add nixos/secrets.yaml
git commit -m "chore(secrets): rotate service credentials"
git push

On the server, pulling and rebuilding will activate the updated secrets into /run/secrets/.


🔑 Workstation Key Bootstrapping

If setting up a new workstation, generate your operator age key pair:

mkdir -p ~/.config/sops/age
age-keygen -o ~/.config/sops/age/keys.txt
chmod 600 ~/.config/sops/age/keys.txt

To print the public key for addition to Core/.sops.yaml:

grep "public key" ~/.config/sops/age/keys.txt