ワンクリックで
managing-secrets
How secrets are stored, decrypted, and used on the devbox. Use when adding, removing, or debugging secrets.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
How secrets are stored, decrypted, and used on the devbox. Use when adding, removing, or debugging secrets.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Use on any NixOS host (devbox on Hetzner, cloudbox on GCP) when SSH connection fails, host key mismatch, NixOS issues, CPU/IO contention (high load), or verifying the host is properly configured
Launch headless opencode sessions from CLI. Use when you need to start a new opencode session in the background to work on a task in parallel, or when spawning work on a specific directory.
How to apply configuration changes to NixOS hosts (devbox, cloudbox). Use when you need to rebuild the system, apply home-manager changes, or recover from issues.
Use when setting up or rotating PagerDuty MCP auth for OpenCode on macOS Keychain or cloudbox sops, or when debugging missing PagerDuty tools.
Use when setting up or rotating Rollbar MCP auth for OpenCode on macOS Keychain or cloudbox sops, when triaging a Rollbar error paged via PagerDuty, or when debugging missing Rollbar tools.
Documents the OpenCode agent set — what each does, when to use it, and why the others were cut. Use when questioning agent choices or considering adding/removing agents.
| name | managing-secrets |
| description | How secrets are stored, decrypted, and used on the devbox. Use when adding, removing, or debugging secrets. |
Secrets are managed with sops-nix using age encryption. They're encrypted in the repo and auto-decrypted at boot.
| Secret | Usage | How it's consumed |
|---|---|---|
github_ssh_key | Git operations | Deployed to ~/.ssh/id_ed25519_github |
cloudflared_tunnel_token | Cloudflare tunnel | Systemd service reads from /run/secrets/ |
cloudflare_api_token | Wrangler CLI | Exported as CLOUDFLARE_API_TOKEN in bash |
claude_personal_oauth_token | Personal Anthropic subscription auth for the @ex-machina/opencode-anthropic-auth opencode plugin (Claude Code is not installed; the env-var name is what the plugin requires). | Exported as CLAUDE_CODE_OAUTH_TOKEN in bash and in opencode-serve's systemd service. |
ccr_api_key | Pigeon daemon | Read by systemd ExecStart from /run/secrets/ |
telegram_bot_token | Pigeon daemon | Read by systemd ExecStart from /run/secrets/ |
telegram_chat_id | Pigeon daemon | Read by systemd ExecStart from /run/secrets/ |
dd_pat | Datadog CLI (dd-cli) + MCP — Personal Access Token (Bearer auth) | Exported as DD_PAT in bash |
secrets/devbox.yaml (encrypted in git)
↓
sops-nix decrypts at boot using /persist/sops-age-key.txt
↓
/run/secrets/<secret_name> (plaintext, mode 0400)
↓
Consumed by: systemd services, bash exports, or file deployment
# Edit encrypted file (requires age key access)
sudo nix-shell -p sops --run "SOPS_AGE_KEY_FILE=/persist/sops-age-key.txt sops secrets/devbox.yaml"
# Or use sops set for non-interactive:
sudo nix-shell -p sops --run "SOPS_AGE_KEY_FILE=/persist/sops-age-key.txt sops set secrets/devbox.yaml '[\"my_new_secret\"]' '\"secret-value\"'"
Edit hosts/devbox/configuration.nix, add to sops.secrets:
sops.secrets = {
# ... existing secrets ...
my_new_secret = {
owner = "dev";
group = "dev";
mode = "0400";
# Optional: deploy to specific path instead of /run/secrets/
# path = "/home/dev/.config/app/secret";
};
};
Option A: Export as env var (for CLI tools)
Edit users/dev/home.linux.nix:
programs.bash.initExtra = lib.mkAfter ''
if [ -r /run/secrets/my_new_secret ]; then
export MY_ENV_VAR="$(cat /run/secrets/my_new_secret)"
fi
'';
Option B: Use in systemd service (for daemons)
systemd.services.my-service = {
serviceConfig = {
ExecStart = "${pkgs.writeShellScript "run" ''
exec my-command --token "$(cat /run/secrets/my_new_secret)"
''}";
};
};
Option C: Deploy as file (for apps expecting file path)
Set path in the secret declaration (Step 2).
git add secrets/devbox.yaml hosts/devbox/configuration.nix
git commit -m "feat: add my_new_secret"
sudo nixos-rebuild switch --flake .#devbox
home-manager switch --flake .#dev # if you added bash export
users/dev/home.linux.nixhosts/devbox/configuration.nixsudo nix-shell -p sops -p yq-go --run "
cd /home/dev/projects/workstation
SOPS_AGE_KEY_FILE=/persist/sops-age-key.txt sops -d secrets/devbox.yaml > /tmp/secrets-plain.yaml
yq -i 'del(.secret_to_remove)' /tmp/secrets-plain.yaml
SOPS_AGE_KEY_FILE=/persist/sops-age-key.txt sops encrypt --age age1kyd7dzxtgte0rcd0nj3chfvcfvammhywe63f25tlsrf8knhf3u8sxp8z9n --input-type yaml --output-type yaml /tmp/secrets-plain.yaml > secrets/devbox.yaml
rm /tmp/secrets-plain.yaml
"
git add -A && git commit -m "chore: remove secret_to_remove"
sudo nixos-rebuild switch --flake .#devbox
| File | Purpose |
|---|---|
secrets/devbox.yaml | Encrypted secrets (committed to git) |
secrets/.sops.yaml | sops config (which keys can decrypt) |
/persist/sops-age-key.txt | Age private key (never in git, root-only) |
hosts/devbox/configuration.nix | Secret declarations for sops-nix |
users/dev/home.linux.nix | Bash exports for env vars |
The age key is root-only. Use sudo with nix-shell:
sudo nix-shell -p sops --run "SOPS_AGE_KEY_FILE=/persist/sops-age-key.txt sops secrets/devbox.yaml"
sops.secrets in configuration.nixsudo nixos-rebuild switch (not just home-manager)ls -la /run/secrets/home.linux.nix (not home.nix - that's shared with Darwin)home-manager switch/persist/ which survives rebuilds but not re-provisioninghome.linux.nix so they only apply on devbox, not Darwin