Brain Structural Validation / Validate Markdown Structure & Links (push) Failing after 8s
6.8 KiB
6.8 KiB
type, status, project, tags
| type | status | project | tags | |||||
|---|---|---|---|---|---|---|---|---|
| plan | completed | nixos |
|
Plan: Secrets Management Architecture & Workstation Boundary Refinement
1. Executive Summary & Diagnostic
The failure encountered when running:
ssh server-remote "sops ~/Core/nixos/secrets.yaml"
is expected and secure by design. It highlights the fundamental GitOps distinction between Secret Authoring and Secret Consumption.
graph LR
subgraph "Workstation (Operator / Author)"
LAPTOP_KEY["~/.config/sops/age/keys.txt<br/>(&laptop private key)"]
SOPS_CLI["sops CLI<br/>(home/dev.nix)"]
CORE_LOCAL["Core/nixos/secrets.yaml<br/>(Git clone on laptop)"]
LAPTOP_KEY --> SOPS_CLI
SOPS_CLI -->|Author & Encrypt| CORE_LOCAL
end
CORE_LOCAL -->|"git push / pull"| CORE_REMOTE["~/Core/nixos/secrets.yaml<br/>(Server clone)"]
subgraph "Server (Consumer / Runtime)"
HOST_SSH["/etc/ssh/ssh_host_ed25519_key<br/>(&server private key)"]
SOPS_NIX["sops-nix systemd service<br/>(Runs as root at boot)"]
RAM_FS["/run/secrets/*<br/>(Decrypted into RAM only)"]
CORE_REMOTE --> SOPS_NIX
HOST_SSH --> SOPS_NIX
SOPS_NIX --> RAM_FS
end
Why It Failed on the Server
- The Server is a Consumer, Not an Author: The server only possesses its host SSH private key (
/etc/ssh/ssh_host_ed25519_key). This key is owned byroot:rootwith permissions0600. - When SSHing as
kiskaadeeand runningsops, the unprivileged user has no access to/etc/ssh/ssh_host_ed25519_keyand has no~/.config/sops/age/keys.txt. - Systemd, running as root during system activation, is what reads
/etc/ssh/ssh_host_ed25519_keyto decrypt secrets into/run/secrets/for Docker and Traefik. - Editing secrets locally on the workstation is the intended, standard GitOps workflow. The workstation holds
~/.config/sops/age/keys.txt(&laptop), allowing decryption, editing, and encryption ofCore/nixos/secrets.yamlbefore pushing.
2. Industry Analysis: Is SOPS Good for a Homelab?
| Secret Management Pattern | How It Works | Suitability for Homelab | Verdict |
|---|---|---|---|
| SOPS + age (GitOps) | Ciphertext stored in Git; host SSH keys decrypt at boot; operator age key edits on laptop. | Ideal. Zero recurring costs, 100% reproducible from Git, offline-capable, native sops-nix integration. |
Industry Standard for NixOS & Kubernetes homelabs |
| HashiCorp Vault / OpenBao | Centralized secrets daemon; dynamic leasing; token authentication. | Poor. High operational overhead, heavy resource footprint, chicken-and-egg unsealing problem on reboot. | Overkill for a single-server setup |
| SaaS Secret Managers (Doppler / 1Password / Infisical) | Secrets fetched over HTTP API at boot. | Moderate. Introduces an external internet dependency; boot fails if WAN is down or API is rate-limited. | Unnecessary external dependency |
Manual .env / Out-of-band Files |
Manually copying secrets onto the server via scp/rsync. | Fragile. Not declarative, breaks disaster recovery, easy to lose during reinstallation. | Antipattern |
Conclusion: SOPS + age is the gold standard for NixOS homelabs. It strikes the ideal balance: zero external dependencies, seamless disaster recovery from Git, and root-level automated decryption via host SSH keys.
3. What Does This Mean for Config (The Laptop)?
We strictly distinguish between Secrets Tooling and Declarative System Secrets:
- Secrets Tooling (Kept): The laptop is the administrative cockpit. It needs
sops,age, andrbwinstalled as CLI packages inhome/dev.nix, and the personal age key in~/.config/sops/age/keys.txt. This enables authoring and rotating secrets forCore. - Declarative Host Secrets (
sops-nixinConfig):- The laptop declares zero host secrets. It does not run headless server daemons, Docker credentials, or database connection strings.
- Retaining
sops-nixas an imported NixOS module inflake.nixand keeping a stale.sops.yamlinConfigcreates an architectural ghost. - Resolution:
- Remove
sops-nixfromConfig/flake.nixand deleteConfig/.sops.yaml. - Keep
sops,age, andrbwinhome/dev.nix. - If the workstation ever requires declarative machine secrets in the future (e.g., enterprise VPN profiles or WiFi PSKs),
sops-nixcan be reintroduced with a single workstation-specific.sops.yaml.
- Remove
4. Workstation Refinement Implementation
Component A: Secrets & Flake Hygiene
- Clarify Secrets Architecture: Document that
Coreowns homelab secrets, whileConfigowns administrative CLI tooling. - Purge Stale Secrets Config:
- Removed
sops-nixflake input fromflake.nix. - Removed root
.sops.yamlfromConfig. - Retained
sops,age, andrbwinhome/dev.nix. - Replaced
docs/secrets-management.mdwith an operator runbook explaining how to manageCoresecrets from the laptop.
- Removed
Component B: Compositor Cleanliness (Niri-Only)
- Remove Hyprland Residue:
- In
home/desktop.nix: Deletedsystemd.user.targets.hyprland-session. - In
home/scripts/record.sh: Strippedhyprctlchecks, leaving clean, optimized Niri logic.
- In
Component C: Boundary Decoupling ($HOME/Core/scripts)
- Eliminate Filesystem Coupling:
- In
home/default.nixandhome/shell.nix: Removed$HOME/Core/scriptsfromsessionPathandPATH. - Workstation path now strictly includes
$HOME/.local/binand$HOME/.cargo/bin.
- In
Component D: Semantic & Architectural Precision
- Precision in
architecture.md:- Refined "Git is the source of truth" to specify reproducible configuration decisions, acknowledging runtime state (SSH keys, machine-id, caches).
- Documented dual-composition root (
flake.nix->system/+home/). - Updated package placement invariant around ownership and execution context (privileged machine vs interactive user environment).
- Added explicit architectural clarification: Workstation remote-access capabilities (OpenSSH) ≠ server infrastructure.
- Semantic Header in
system/hardware.nix:- Re-titled module scope from "Laptop Hardware" to "Machine Services & Peripherals" (to logically house PipeWire, Docker, Bluetooth, printing).
- Documentation Sweep:
- Fixed stale
modules/user/terminal.nixreference indocs/tmux.md. - Purged lingering legacy references across all docs.
- Fixed stale
5. Verification
nix flake check— Flake inputs and schemas evaluated cleanly.nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link— Full dry build succeeded cleanly.- Live rebuild test and switch completed successfully.