feat: sops-nix secrets management
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
2d7c936d80
commit
ab550cd0a7
4 changed files with 85 additions and 0 deletions
13
.sops.yaml.example
Normal file
13
.sops.yaml.example
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
keys:
|
||||||
|
# Your age PUBLIC key. Generate a keypair with:
|
||||||
|
# age-keygen -o ~/.config/sops/age/keys.txt
|
||||||
|
# then paste the "Public key:" line below (starts with "age1...").
|
||||||
|
# Copy this file to .sops.yaml and fill it in.
|
||||||
|
# pragma: allowlist secret
|
||||||
|
- &admin age1REPLACE_WITH_YOUR_AGE_PUBLIC_KEY
|
||||||
|
|
||||||
|
creation_rules:
|
||||||
|
- path_regex: secrets/.*\.yaml$
|
||||||
|
key_groups:
|
||||||
|
- age:
|
||||||
|
- *admin
|
||||||
23
modules/secrets.nix
Normal file
23
modules/secrets.nix
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
# sops-nix per-host wiring.
|
||||||
|
#
|
||||||
|
# The sops-nix module itself is injected by lib/mksystem.nix. This
|
||||||
|
# file points sops at the omni default file and the host's age
|
||||||
|
# key. Secrets are exposed to services as files under
|
||||||
|
# /run/secrets/<name>, declared per-secret via `sops.secrets.<name>`
|
||||||
|
# in the module that consumes them.
|
||||||
|
#
|
||||||
|
# Recipients live in /etc/nixos/.sops.yaml; the matching age key
|
||||||
|
# lives at ~/.config/sops/age/keys.txt on omni/bohm.
|
||||||
|
|
||||||
|
let
|
||||||
|
sopsFile = ../secrets/omni.yaml;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
sops = lib.mkIf (builtins.pathExists sopsFile) {
|
||||||
|
defaultSopsFile = sopsFile;
|
||||||
|
defaultSopsFormat = "yaml";
|
||||||
|
age.keyFile = "/home/padreug/.config/sops/age/keys.txt";
|
||||||
|
};
|
||||||
|
}
|
||||||
37
secrets/README.md
Normal file
37
secrets/README.md
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
# omni secrets (sops-nix)
|
||||||
|
|
||||||
|
Encrypted YAML files in this directory are decrypted at NixOS
|
||||||
|
activation time and exposed under `/run/secrets/<name>` for the
|
||||||
|
services that declare `sops.secrets.<name>` to consume.
|
||||||
|
|
||||||
|
Recipients are declared in `../.sops.yaml`. On omni/bohm the
|
||||||
|
matching private key lives at `~/.config/sops/age/keys.txt`.
|
||||||
|
|
||||||
|
## Workflow
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# First-time: create + encrypt the omni default file
|
||||||
|
sops secrets/omni.yaml
|
||||||
|
# adds the sops: metadata block and encrypts in place
|
||||||
|
|
||||||
|
# Later edits go through sops (auto-decrypts, re-encrypts on save)
|
||||||
|
sops secrets/omni.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
## First migration targets
|
||||||
|
|
||||||
|
See `../modules/mcp.nix` for the current plaintext-file references
|
||||||
|
that should move under sops:
|
||||||
|
|
||||||
|
- `forgejo-token` — Forgejo personal access token (forgejo-mcp)
|
||||||
|
- `lnbits-admin-key` — LNbits admin API key (lnbits-mcp)
|
||||||
|
|
||||||
|
Once `secrets/omni.yaml` exists and is encrypted, declare each in
|
||||||
|
the consuming module:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
sops.secrets.forgejo-token = { mode = "0400"; owner = config.omni.user; };
|
||||||
|
```
|
||||||
|
|
||||||
|
and switch the path reference (e.g. `forgejoTokenFile`) to
|
||||||
|
`config.sops.secrets.forgejo-token.path`.
|
||||||
12
secrets/omni.yaml.example
Normal file
12
secrets/omni.yaml.example
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
# Template secrets file. Copy to secrets/omni.yaml, then encrypt in
|
||||||
|
# place with sops (uses the recipient in ../.sops.yaml):
|
||||||
|
#
|
||||||
|
# cp secrets/omni.yaml.example secrets/omni.yaml
|
||||||
|
# sops secrets/omni.yaml
|
||||||
|
#
|
||||||
|
# modules/secrets.nix only activates sops when omni.secrets.enable is
|
||||||
|
# set AND this file exists, so the config evaluates fine without it.
|
||||||
|
# Keys below are examples the modules consume — adjust to taste.
|
||||||
|
forgejo-token: REPLACE_ME
|
||||||
|
lnbits-admin-key: REPLACE_ME
|
||||||
|
nextcloud-password: REPLACE_ME
|
||||||
Loading…
Add table
Add a link
Reference in a new issue