fix(mars): deliver the ElevenLabs key through Hermes' .env
The image's s6 init hands the gateway a fixed set of container env vars;
ELEVENLABS_API_KEY is not one of them, so --env-file alone left
text_to_speech reporting it unset even though the var was in the
container config and the resolver read os.environ fine.
prepare-dirs now merges the single line into ${hermesHome}/.env
(HERMES_HOME=/opt/data), as uid 986 so root never writes into hermesHome,
with the key on an fd opened as root so it stays out of argv and the journal.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -181,7 +181,7 @@ in
|
||||
wants = [ "network-online.target" ];
|
||||
after = [ "network-online.target" ];
|
||||
unitConfig.RequiresMountsFor = [ "/mnt/jupiter" ];
|
||||
path = [ pkgs.git pkgs.tea pkgs.curl pkgs.coreutils pkgs.yq-go ];
|
||||
path = [ pkgs.git pkgs.tea pkgs.curl pkgs.coreutils pkgs.yq-go pkgs.gnugrep pkgs.util-linux ];
|
||||
serviceConfig.Type = "oneshot";
|
||||
# Everything here is either local or bounded to ~30s by the probe loop, so
|
||||
# anything past two minutes is a hang, not slowness.
|
||||
@@ -265,6 +265,25 @@ in
|
||||
chmod --reference="$conf" "$conf.new"
|
||||
mv -f "$conf.new" "$conf"
|
||||
|
||||
# The image's s6 init hands the gateway a fixed set of container env vars,
|
||||
# and ELEVENLABS_API_KEY isn't among them (OPENCODE_GO_API_KEY is) — so the
|
||||
# key only reaches Hermes via .env, which load_env() reads directly.
|
||||
# Re-asserted every start: a sops rotation must win over a stale line.
|
||||
# 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.
|
||||
setpriv --reuid=${hermesUid} --regid=${hermesGid} --clear-groups \
|
||||
${pkgs.runtimeShell} -c '
|
||||
set -eu
|
||||
envf=$1
|
||||
umask 077
|
||||
key=$(cat)
|
||||
[ -e "$envf" ] || : > "$envf"
|
||||
{ grep -v "^ELEVENLABS_API_KEY=" "$envf" || true
|
||||
printf "ELEVENLABS_API_KEY=%s\n" "$key"; } > "$envf.new"
|
||||
mv -f "$envf.new" "$envf"
|
||||
' _ ${hermesHome}/.env < ${config.sops.secrets.elevenlabs_api_key.path}
|
||||
|
||||
if [ -d ${hermesHome}/.config ]; then
|
||||
chown ${hermesUid}:${hermesGid} ${hermesHome}/.config
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user