Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions home/common/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1157,13 +1157,28 @@ 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" ''
set -eu
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";
Expand Down
3 changes: 3 additions & 0 deletions nixos/services/pm-stack/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading