Secrets¶
Secrets are managed with sops-nix. Plaintext secrets never go into
.nix files or the Nix store.
How it works¶
- Encrypted files:
secrets/*.yaml(currentlyingress.yaml,vaultwarden.yaml, ...) - Encryption policy
.sops.yaml: files matchingsecrets/[^/]+\.yamlare encrypted for thepoby,yggdrasil, andmidgardage recipients. - Each host decrypts using its own SSH host key
(
/etc/ssh/ssh_host_ed25519_key) as the age identity, so only hosts registered in.sops.yamlcan read the secrets. - At activation/runtime, sops-nix materializes secrets as files under
/run/secretsor as service-specific templates, applying owner, group, and mode.
Adding a new secret¶
-
Open the appropriate
secrets/*.yamlwith sops and edit it.sops secrets/ingress.yaml -
Declare it in the module with
sops.secrets."<path>", setting owner/mode andrestartUnits.sops.secrets."myservice/api_token" = { owner = "myservice"; mode = "0400"; restartUnits = ["myservice.service"]; }; -
Reference it from the service via
config.sops.secrets."<path>".path, or render an environment file withsops.templates.
Current secret consumers¶
| Secret | Consumer | Purpose |
|---|---|---|
cloudflare/caddy_env |
Caddy | Cloudflare API token for DNS challenges |
cloudflare/cloudflared_tunnel_credentials |
cloudflared | Tunnel credential |
grafana/admin_password |
Grafana | administrator password |
vaultwarden/admin_token |
Vaultwarden | admin token (ADMIN_TOKEN) |
Adding a new host as a recipient¶
-
Derive the age recipient key from the new host's SSH host public key.
ssh-keyscan -t ed25519 <host> | ssh-to-age -
Add the recipient to
.sops.yaml. -
Re-encrypt the existing secret files.
sops updatekeys secrets/<file>.yaml