feat(mars): expose luna over the OpenAI-compatible API server
API_SERVER_ENABLED/HOST/PORT in the env template, bound 0.0.0.0 for the
same reason the dashboard is: the container is --network=host and nothing
opens 8642 in the firewall, so it is reachable over tailscale0 only.
API_SERVER_KEY has to go through .env like the ElevenLabs key did
(461d6cc). Confirmed the same way: with the key set only in the container
env the server came up — so API_SERVER_ENABLED/HOST *did* pass through —
but answered every bearer token with "Invalid gateway API key". The s6
passthrough list carries the plain API_SERVER_* vars and drops the secret
one. The .env write is now a write_env_key helper so both keys share it.
restartUnits gains prepare-dirs, which is what writes the .env line; the
container then has to come back up to read it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -272,17 +272,28 @@ in
|
||||
# setpriv because root must not write into hermesHome — luna could plant a
|
||||
# symlink there. The key arrives on an fd opened while still root, so it
|
||||
# never lands in argv or the journal and her uid needs no /run/secrets access.
|
||||
#
|
||||
# API_SERVER_KEY is in the same boat, confirmed the same way: with it set
|
||||
# only in the container env the server came up (so API_SERVER_ENABLED/HOST
|
||||
# DID pass through) but answered every bearer token with
|
||||
# "Invalid gateway API key" — the passthrough list carries the plain
|
||||
# API_SERVER_* vars and drops the secret one.
|
||||
write_env_key() {
|
||||
setpriv --reuid=${hermesUid} --regid=${hermesGid} --clear-groups \
|
||||
${pkgs.runtimeShell} -c '
|
||||
set -eu
|
||||
envf=$1
|
||||
name=$2
|
||||
umask 077
|
||||
key=$(cat)
|
||||
[ -e "$envf" ] || : > "$envf"
|
||||
{ grep -v "^ELEVENLABS_API_KEY=" "$envf" || true
|
||||
printf "ELEVENLABS_API_KEY=%s\n" "$key"; } > "$envf.new"
|
||||
{ grep -v "^$name=" "$envf" || true
|
||||
printf "%s=%s\n" "$name" "$key"; } > "$envf.new"
|
||||
mv -f "$envf.new" "$envf"
|
||||
' _ ${hermesHome}/.env < ${config.sops.secrets.elevenlabs_api_key.path}
|
||||
' _ ${hermesHome}/.env "$1"
|
||||
}
|
||||
write_env_key ELEVENLABS_API_KEY < ${config.sops.secrets.elevenlabs_api_key.path}
|
||||
write_env_key API_SERVER_KEY < ${config.sops.secrets.hermes_api_server_key.path}
|
||||
|
||||
if [ -d ${hermesHome}/.config ]; then
|
||||
chown ${hermesUid}:${hermesGid} ${hermesHome}/.config
|
||||
|
||||
@@ -40,6 +40,18 @@
|
||||
sops.secrets.gitea_hermes_webhook_secret = {
|
||||
restartUnits = [ "hermes-agent-webhook-routes.service" ];
|
||||
};
|
||||
# Bearer token for the OpenAI-compatible API server (see the env template
|
||||
# below). Same value in secrets/terra.yaml, where luna-voiced reads it.
|
||||
# API_SERVER_HOST=0.0.0.0 for the same reason the dashboard binds it (see
|
||||
# hermes-agent.nix): the container is --network=host and nothing opens 8642
|
||||
# in the firewall, so it is reachable over tailscale0 only — LAN-closed.
|
||||
# prepare-dirs writes it into luna's .env (the container env alone does not
|
||||
# reach the gateway — see hermes-agent.nix); the container then has to come
|
||||
# back up to read it.
|
||||
sops.secrets.hermes_api_server_key.restartUnits = [
|
||||
"hermes-agent-prepare-dirs.service"
|
||||
"podman-hermes-agent.service"
|
||||
];
|
||||
sops.templates."hermes-agent.env".content = ''
|
||||
OPENCODE_GO_API_KEY=${config.sops.placeholder.opencode_go_api_key}
|
||||
TELEGRAM_BOT_TOKEN=${config.sops.placeholder.telegram_bot_token}
|
||||
@@ -49,6 +61,10 @@
|
||||
WEBHOOK_PORT=8644
|
||||
HERMES_DASHBOARD_OIDC_CLIENT_SECRET=${config.sops.placeholder.hermes_dashboard_oidc_client_secret}
|
||||
ELEVENLABS_API_KEY=${config.sops.placeholder.elevenlabs_api_key}
|
||||
API_SERVER_ENABLED=true
|
||||
API_SERVER_HOST=0.0.0.0
|
||||
API_SERVER_PORT=8642
|
||||
API_SERVER_KEY=${config.sops.placeholder.hermes_api_server_key}
|
||||
'';
|
||||
|
||||
# luna's gitea push token (services/dev/gitea.nix provisions the account +
|
||||
|
||||
Reference in New Issue
Block a user