From 15a34447b25d4314502952e8310cb77b1b72f08b Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Fri, 30 Oct 2026 18:40:09 -0500 Subject: [PATCH] fix(openclaw): land sops-nix secrets on main + repoint wrappers to /run/secrets/openclaw Lands PR #1242's stranded change (previously merged into feat/openclaw-summarize only): nixos/hosts/amd-openclaw-secrets.nix + its import in the amd host modules. The bws.yaml half of #1242 is already on main (the three openclaw.* keys, re-mirrored since), so it is not re-landed. Repoints the home/openclaw wrapper environment paths (gateway, Slack bot/app tokens) and the matching docs from ~/.secrets/openclaw/* to /run/secrets/openclaw/*, where sops-nix decrypts them at activation. Refs #1558 --- home/openclaw/README.md | 2 +- home/openclaw/default.nix | 11 ++++++----- home/openclaw/workspace/CHANNELS.md | 2 +- home/openclaw/workspace/TOOLS.md | 2 +- nixos/hosts/amd-openclaw-secrets.nix | 22 ++++++++++++++++++++++ nixos/hosts/default.nix | 1 + 6 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 nixos/hosts/amd-openclaw-secrets.nix diff --git a/home/openclaw/README.md b/home/openclaw/README.md index b2d3e85c31..1103dbeec8 100644 --- a/home/openclaw/README.md +++ b/home/openclaw/README.md @@ -9,7 +9,7 @@ source in the fleet next to Muse (Archer) and Aster (Dot). It is installed - **Service:** systemd user unit `openclaw-gateway` (linger is on, so it starts at boot). Logs: `journalctl --user -u openclaw-gateway -f`. - **Control UI / WebChat:** `http://amd-6.raptor-pumpkinseed.ts.net:18789/` - (tailnet bind, token auth). Token: `~/.secrets/openclaw/gateway-token` + (tailnet bind, token auth). Token: `/run/secrets/openclaw/gateway-token` (0600, machine-local, never in git or the Nix store). - **Config:** `programs.openclaw` in `default.nix` here; rendered to `~/.openclaw/openclaw.json` at activation. Nix mode is on: change the diff --git a/home/openclaw/default.nix b/home/openclaw/default.nix index cedd9c5d29..1d25cb2e54 100644 --- a/home/openclaw/default.nix +++ b/home/openclaw/default.nix @@ -18,8 +18,9 @@ # into ~/.openclaw/workspace) for the knowledge pack it runs with. # # Secrets: referenced by path/name only, never values. The gateway token -# lives in ~/.secrets/openclaw/gateway-token (0600, created on the machine, -# not in git, not in the Nix store) and is read at service start. +# lives in /run/secrets/openclaw/gateway-token (decrypted by sops-nix at +# activation from secrets/sops/common/bws.yaml; never in git or the Nix +# store) and is read at service start. let homeDir = "/home/user"; # Local provider-proxy ports. The canonical definitions live in @@ -90,9 +91,9 @@ in # from that file at service start (nix-openclaw runtime contract), so # the token itself never enters the store. environment = { - OPENCLAW_GATEWAY_TOKEN = "${homeDir}/.secrets/openclaw/gateway-token"; - OPENCLAW_SLACK_BOT_TOKEN = "/home/user/.secrets/openclaw/slack-bot-token"; - OPENCLAW_SLACK_APP_TOKEN = "/home/user/.secrets/openclaw/slack-app-token"; + OPENCLAW_GATEWAY_TOKEN = "/run/secrets/openclaw/gateway-token"; + OPENCLAW_SLACK_BOT_TOKEN = "/run/secrets/openclaw/slack-bot-token"; + OPENCLAW_SLACK_APP_TOKEN = "/run/secrets/openclaw/slack-app-token"; }; # Extra binaries on the gateway's PATH (not the login shell's): diff --git a/home/openclaw/workspace/CHANNELS.md b/home/openclaw/workspace/CHANNELS.md index 5a0e90707e..ebe50c3dae 100644 --- a/home/openclaw/workspace/CHANNELS.md +++ b/home/openclaw/workspace/CHANNELS.md @@ -2,7 +2,7 @@ ## Live today -- **Control UI / WebChat** — the gateway UI on the tailnet: `http://amd-6.raptor-pumpkinseed.ts.net:18789/` (token auth; token at `~/.secrets/openclaw/gateway-token`). Also the `openclaw` CLI on this laptop (`openclaw agent --message "…"`, `openclaw status`, `openclaw doctor`). +- **Control UI / WebChat** — the gateway UI on the tailnet: `http://amd-6.raptor-pumpkinseed.ts.net:18789/` (token auth; token at `/run/secrets/openclaw/gateway-token`). Also the `openclaw` CLI on this laptop (`openclaw agent --message "…"`, `openclaw status`, `openclaw doctor`). - **ACP coding sessions** from any connected surface: `/acp spawn opencode` (the only ACP harness wired so far; Claude/Codex run via their native runtime plugins). ## Plugins loaded, channels pending Drew's one-time setup diff --git a/home/openclaw/workspace/TOOLS.md b/home/openclaw/workspace/TOOLS.md index fe59419b7d..84681085ca 100644 --- a/home/openclaw/workspace/TOOLS.md +++ b/home/openclaw/workspace/TOOLS.md @@ -36,4 +36,4 @@ For real coding, spawn an ACP session instead of improvising: `/acp spawn openco - The system flake is `~/code/flake.nix`; host `amd`. Apply user-level changes with the Home Manager activation package from that flake; full `sudo nixos-rebuild switch --flake ~/code#amd` is Drew's to run (sudo needs his password). - Never scatter code in $HOME — code goes in developing-today/code (private/sensitive material: dezren39/hatch-personal). -- Secrets are referenced **by name only** (Bitwarden Secrets Manager / sops under `/run/secrets/agent-auth/`). Never write a secret value into a file, commit, chat, or log. This gateway's own token lives at `~/.secrets/openclaw/gateway-token` (0600, not in git, not in the Nix store). +- Secrets are referenced **by name only** (Bitwarden Secrets Manager / sops under `/run/secrets/agent-auth/`). Never write a secret value into a file, commit, chat, or log. This gateway's own token lives at `/run/secrets/openclaw/gateway-token` (0600, not in git, not in the Nix store). diff --git a/nixos/hosts/amd-openclaw-secrets.nix b/nixos/hosts/amd-openclaw-secrets.nix new file mode 100644 index 0000000000..2dcfed5ee6 --- /dev/null +++ b/nixos/hosts/amd-openclaw-secrets.nix @@ -0,0 +1,22 @@ +{ lib, ... }: +let + userSecret = key: { + inherit key; + sopsFile = lib.from-root "secrets/sops/common/bws.yaml"; + owner = "user"; + mode = "0400"; + }; +in +{ + # OpenClaw gateway + channel tokens. Bitwarden Secrets Manager is the + # source of truth; lib/bws-to-sops.sh mirrors every bws secret into + # secrets/sops/common/bws.yaml (age-encrypted to this host). sops-nix + # decrypts these at system activation to /run/secrets/openclaw/*, + # where the openclaw-gateway user service reads them through the + # wrapper's file-based environment (see home/openclaw). + sops.secrets = { + "openclaw/gateway-token" = userSecret "openclaw.gateway-token"; + "openclaw/slack-bot-token" = userSecret "openclaw.slack-bot-token"; + "openclaw/slack-app-token" = userSecret "openclaw.slack-app-token"; + }; +} diff --git a/nixos/hosts/default.nix b/nixos/hosts/default.nix index f34203031b..48cf0795f2 100644 --- a/nixos/hosts/default.nix +++ b/nixos/hosts/default.nix @@ -117,6 +117,7 @@ in # see the file for the one-time on-machine credential setup. ./amd-krdp.nix ./amd-ipv4-preference.nix + ./amd-openclaw-secrets.nix ]; }; # amd-server = host {