diff --git a/home/common/default.nix b/home/common/default.nix index 2a1342913b..8158606a33 100644 --- a/home/common/default.nix +++ b/home/common/default.nix @@ -1157,6 +1157,17 @@ in # "mistral") is its source — verified live 2026-11-06 (the leg # returns the API-budget 402, not an auth error, with the env var # absent). + # ANTIGRAVITY_OAUTH_CLIENT_SECRET for the same server: the + # _antigravity provider refreshes the agy keyring token with the agy + # installed-app client's secret, read from the process environment + # since fork commit 80d6b2f1f6 (2026-11-08) retired the runtime + # extraction from the agy binary. The value lives in the vault as + # google.antigravity-oauth-client-secret (one-time extraction from + # the installed agy binary, sanctioned by Drew 2026-11-09, code#8086) + # and the materializer below fetches it by name into the same + # EnvironmentFile at every server start — it is never stored in this + # repo or the Nix store. The quota gatherer reads the same file (see + # nixos/services/pm-stack) so its `opencode quota` refresh works too. systemd.user.services.opencode.Service = { ExecStartPre = toString ( pkgs.writeShellScript "opencode-env-key-materialize" '' @@ -1164,6 +1175,10 @@ in umask 077 mkdir -p "$HOME/.local/state/opencode" printf 'DEEPSEEK_API_KEY=%s\n' "$(cat /run/secrets/agent-auth/deepseek-api-key)" >> "$HOME/.local/state/opencode/mistral-api-key.env" + agy_client_secret="$("${fleetPkgs.fleet}/bin/fleet" secrets get google.antigravity-oauth-client-secret 2>/dev/null || true)" + if [ -n "$agy_client_secret" ]; then + printf 'ANTIGRAVITY_OAUTH_CLIENT_SECRET=%s\n' "$agy_client_secret" >> "$HOME/.local/state/opencode/mistral-api-key.env" + fi '' ); EnvironmentFile = "%h/.local/state/opencode/mistral-api-key.env"; diff --git a/nixos/services/pm-stack/default.nix b/nixos/services/pm-stack/default.nix index 417b78b37d..9d1cbb4bb0 100644 --- a/nixos/services/pm-stack/default.nix +++ b/nixos/services/pm-stack/default.nix @@ -237,6 +237,9 @@ in Type = "oneshot"; TimeoutStartSec = 300; WorkingDirectory = "${repo}/pm-stack/aggregator"; + # ANTIGRAVITY_OAUTH_CLIENT_SECRET for the quota subcommand's Antigravity token refresh (code#8086); + # the file is materialized by the opencode unit's ExecStartPre (home/common). + EnvironmentFile = "-%h/.local/state/opencode/mistral-api-key.env"; Environment = [ "QUOTA_CURRENT_PATH=${aggState}/quota-current.json" "QUOTA_HEARTBEAT_PATH=${aggState}/quota-gatherer-heartbeat.json"