diff --git a/.beads/.gitignore b/.beads/.gitignore index df4911d..3121a59 100644 --- a/.beads/.gitignore +++ b/.beads/.gitignore @@ -71,3 +71,10 @@ bd.db # They would override fork protection in .git/info/exclude. # Config files (metadata.json, config.yaml) are tracked by git by default # since no pattern above ignores them. + +# Added by bd (missing required patterns) +*.gate.lock* +last_pull +proxieddb/ +dolt-server-config.yaml +proxied_server_client_info.json diff --git a/.beads/config.yaml b/.beads/config.yaml index d909ee4..a927682 100644 --- a/.beads/config.yaml +++ b/.beads/config.yaml @@ -53,4 +53,5 @@ # - github.org # - github.repo -sync.remote: "git+ssh://gitea@code.m3ta.dev/m3tam3re/nixos-config.git" \ No newline at end of file +sync: + remote: "git+ssh://gitea@code.m3ta.dev/m3tam3re/nixos-config.git" diff --git a/.beads/hooks/post-checkout b/.beads/hooks/post-checkout index d485872..9d53a6f 100755 --- a/.beads/hooks/post-checkout +++ b/.beads/hooks/post-checkout @@ -1,24 +1,59 @@ #!/usr/bin/env sh -# --- BEGIN BEADS INTEGRATION v1.0.3 --- +# --- BEGIN BEADS INTEGRATION v1.3.2 --- # This section is managed by beads. Do not remove these markers. if command -v bd >/dev/null 2>&1; then export BD_GIT_HOOK=1 _bd_timeout=${BEADS_HOOK_TIMEOUT:-300} - if command -v timeout >/dev/null 2>&1; then - timeout "$_bd_timeout" bd hooks run post-checkout "$@" - _bd_exit=$? - if [ $_bd_exit -eq 124 ]; then - echo >&2 "beads: hook 'post-checkout' timed out after ${_bd_timeout}s — continuing without beads" + case "$_bd_timeout" in + *[!0-9]*|'') _bd_timeout_invalid=1 ;; + *[1-9]*) _bd_timeout_invalid=0 ;; + *) _bd_timeout_invalid=1 ;; + esac + if [ "$_bd_timeout_invalid" -eq 1 ]; then + echo >&2 "beads: invalid BEADS_HOOK_TIMEOUT; using 300 seconds" + _bd_timeout=300 + fi + _bd_timeout_backend=none + _bd_timeout_command= + for _bd_timeout_candidate in timeout gtimeout; do + if command -v "$_bd_timeout_candidate" >/dev/null 2>&1; then + if _bd_timeout_version="$("$_bd_timeout_candidate" --version 2>/dev/null)"; then + case "$_bd_timeout_version" in + "timeout (GNU coreutils) "*) _bd_timeout_command=$_bd_timeout_candidate; break ;; + esac + fi + fi + done + if [ -n "$_bd_timeout_command" ]; then + _bd_timeout_backend=coreutils + if "$_bd_timeout_command" -- "$_bd_timeout" bd hooks run post-checkout "$@"; then _bd_exit=0 + else + _bd_exit=$? + fi + elif command -v perl >/dev/null 2>&1; then + _bd_timeout_backend=perl + if perl -e 'alarm shift; exec @ARGV' -- "$_bd_timeout" bd hooks run post-checkout "$@"; then + _bd_exit=0 + else + _bd_exit=$? fi else - bd hooks run post-checkout "$@" - _bd_exit=$? + echo >&2 "beads: hook 'post-checkout' running without timeout; install coreutils or perl to enable BEADS_HOOK_TIMEOUT" + if bd hooks run post-checkout "$@"; then + _bd_exit=0 + else + _bd_exit=$? + fi fi - if [ $_bd_exit -eq 3 ]; then + if { [ "$_bd_timeout_backend" = coreutils ] && [ "$_bd_exit" -eq 124 ]; } || { [ "$_bd_timeout_backend" = perl ] && [ "$_bd_exit" -eq 142 ]; }; then + echo >&2 "beads: hook 'post-checkout' timed out after ${_bd_timeout}s — continuing without beads" + _bd_exit=0 + fi + if [ "$_bd_exit" -eq 3 ]; then echo >&2 "beads: database not initialized — skipping hook 'post-checkout'" _bd_exit=0 fi - if [ $_bd_exit -ne 0 ]; then exit $_bd_exit; fi + if [ "$_bd_exit" -ne 0 ]; then exit "$_bd_exit"; fi fi -# --- END BEADS INTEGRATION v1.0.3 --- +# --- END BEADS INTEGRATION v1.3.2 --- diff --git a/.beads/hooks/post-merge b/.beads/hooks/post-merge index 5aa3315..63f2260 100755 --- a/.beads/hooks/post-merge +++ b/.beads/hooks/post-merge @@ -1,24 +1,59 @@ #!/usr/bin/env sh -# --- BEGIN BEADS INTEGRATION v1.0.3 --- +# --- BEGIN BEADS INTEGRATION v1.3.2 --- # This section is managed by beads. Do not remove these markers. if command -v bd >/dev/null 2>&1; then export BD_GIT_HOOK=1 _bd_timeout=${BEADS_HOOK_TIMEOUT:-300} - if command -v timeout >/dev/null 2>&1; then - timeout "$_bd_timeout" bd hooks run post-merge "$@" - _bd_exit=$? - if [ $_bd_exit -eq 124 ]; then - echo >&2 "beads: hook 'post-merge' timed out after ${_bd_timeout}s — continuing without beads" + case "$_bd_timeout" in + *[!0-9]*|'') _bd_timeout_invalid=1 ;; + *[1-9]*) _bd_timeout_invalid=0 ;; + *) _bd_timeout_invalid=1 ;; + esac + if [ "$_bd_timeout_invalid" -eq 1 ]; then + echo >&2 "beads: invalid BEADS_HOOK_TIMEOUT; using 300 seconds" + _bd_timeout=300 + fi + _bd_timeout_backend=none + _bd_timeout_command= + for _bd_timeout_candidate in timeout gtimeout; do + if command -v "$_bd_timeout_candidate" >/dev/null 2>&1; then + if _bd_timeout_version="$("$_bd_timeout_candidate" --version 2>/dev/null)"; then + case "$_bd_timeout_version" in + "timeout (GNU coreutils) "*) _bd_timeout_command=$_bd_timeout_candidate; break ;; + esac + fi + fi + done + if [ -n "$_bd_timeout_command" ]; then + _bd_timeout_backend=coreutils + if "$_bd_timeout_command" -- "$_bd_timeout" bd hooks run post-merge "$@"; then _bd_exit=0 + else + _bd_exit=$? + fi + elif command -v perl >/dev/null 2>&1; then + _bd_timeout_backend=perl + if perl -e 'alarm shift; exec @ARGV' -- "$_bd_timeout" bd hooks run post-merge "$@"; then + _bd_exit=0 + else + _bd_exit=$? fi else - bd hooks run post-merge "$@" - _bd_exit=$? + echo >&2 "beads: hook 'post-merge' running without timeout; install coreutils or perl to enable BEADS_HOOK_TIMEOUT" + if bd hooks run post-merge "$@"; then + _bd_exit=0 + else + _bd_exit=$? + fi fi - if [ $_bd_exit -eq 3 ]; then + if { [ "$_bd_timeout_backend" = coreutils ] && [ "$_bd_exit" -eq 124 ]; } || { [ "$_bd_timeout_backend" = perl ] && [ "$_bd_exit" -eq 142 ]; }; then + echo >&2 "beads: hook 'post-merge' timed out after ${_bd_timeout}s — continuing without beads" + _bd_exit=0 + fi + if [ "$_bd_exit" -eq 3 ]; then echo >&2 "beads: database not initialized — skipping hook 'post-merge'" _bd_exit=0 fi - if [ $_bd_exit -ne 0 ]; then exit $_bd_exit; fi + if [ "$_bd_exit" -ne 0 ]; then exit "$_bd_exit"; fi fi -# --- END BEADS INTEGRATION v1.0.3 --- +# --- END BEADS INTEGRATION v1.3.2 --- diff --git a/.beads/hooks/pre-commit b/.beads/hooks/pre-commit index d7ac3d9..0928485 100755 --- a/.beads/hooks/pre-commit +++ b/.beads/hooks/pre-commit @@ -1,24 +1,59 @@ #!/usr/bin/env sh -# --- BEGIN BEADS INTEGRATION v1.0.3 --- +# --- BEGIN BEADS INTEGRATION v1.3.2 --- # This section is managed by beads. Do not remove these markers. if command -v bd >/dev/null 2>&1; then export BD_GIT_HOOK=1 _bd_timeout=${BEADS_HOOK_TIMEOUT:-300} - if command -v timeout >/dev/null 2>&1; then - timeout "$_bd_timeout" bd hooks run pre-commit "$@" - _bd_exit=$? - if [ $_bd_exit -eq 124 ]; then - echo >&2 "beads: hook 'pre-commit' timed out after ${_bd_timeout}s — continuing without beads" + case "$_bd_timeout" in + *[!0-9]*|'') _bd_timeout_invalid=1 ;; + *[1-9]*) _bd_timeout_invalid=0 ;; + *) _bd_timeout_invalid=1 ;; + esac + if [ "$_bd_timeout_invalid" -eq 1 ]; then + echo >&2 "beads: invalid BEADS_HOOK_TIMEOUT; using 300 seconds" + _bd_timeout=300 + fi + _bd_timeout_backend=none + _bd_timeout_command= + for _bd_timeout_candidate in timeout gtimeout; do + if command -v "$_bd_timeout_candidate" >/dev/null 2>&1; then + if _bd_timeout_version="$("$_bd_timeout_candidate" --version 2>/dev/null)"; then + case "$_bd_timeout_version" in + "timeout (GNU coreutils) "*) _bd_timeout_command=$_bd_timeout_candidate; break ;; + esac + fi + fi + done + if [ -n "$_bd_timeout_command" ]; then + _bd_timeout_backend=coreutils + if "$_bd_timeout_command" -- "$_bd_timeout" bd hooks run pre-commit "$@"; then _bd_exit=0 + else + _bd_exit=$? + fi + elif command -v perl >/dev/null 2>&1; then + _bd_timeout_backend=perl + if perl -e 'alarm shift; exec @ARGV' -- "$_bd_timeout" bd hooks run pre-commit "$@"; then + _bd_exit=0 + else + _bd_exit=$? fi else - bd hooks run pre-commit "$@" - _bd_exit=$? + echo >&2 "beads: hook 'pre-commit' running without timeout; install coreutils or perl to enable BEADS_HOOK_TIMEOUT" + if bd hooks run pre-commit "$@"; then + _bd_exit=0 + else + _bd_exit=$? + fi fi - if [ $_bd_exit -eq 3 ]; then + if { [ "$_bd_timeout_backend" = coreutils ] && [ "$_bd_exit" -eq 124 ]; } || { [ "$_bd_timeout_backend" = perl ] && [ "$_bd_exit" -eq 142 ]; }; then + echo >&2 "beads: hook 'pre-commit' timed out after ${_bd_timeout}s — continuing without beads" + _bd_exit=0 + fi + if [ "$_bd_exit" -eq 3 ]; then echo >&2 "beads: database not initialized — skipping hook 'pre-commit'" _bd_exit=0 fi - if [ $_bd_exit -ne 0 ]; then exit $_bd_exit; fi + if [ "$_bd_exit" -ne 0 ]; then exit "$_bd_exit"; fi fi -# --- END BEADS INTEGRATION v1.0.3 --- +# --- END BEADS INTEGRATION v1.3.2 --- diff --git a/.beads/hooks/pre-push b/.beads/hooks/pre-push index 5af9e7b..24796d1 100755 --- a/.beads/hooks/pre-push +++ b/.beads/hooks/pre-push @@ -1,24 +1,59 @@ #!/usr/bin/env sh -# --- BEGIN BEADS INTEGRATION v1.0.3 --- +# --- BEGIN BEADS INTEGRATION v1.3.2 --- # This section is managed by beads. Do not remove these markers. if command -v bd >/dev/null 2>&1; then export BD_GIT_HOOK=1 _bd_timeout=${BEADS_HOOK_TIMEOUT:-300} - if command -v timeout >/dev/null 2>&1; then - timeout "$_bd_timeout" bd hooks run pre-push "$@" - _bd_exit=$? - if [ $_bd_exit -eq 124 ]; then - echo >&2 "beads: hook 'pre-push' timed out after ${_bd_timeout}s — continuing without beads" + case "$_bd_timeout" in + *[!0-9]*|'') _bd_timeout_invalid=1 ;; + *[1-9]*) _bd_timeout_invalid=0 ;; + *) _bd_timeout_invalid=1 ;; + esac + if [ "$_bd_timeout_invalid" -eq 1 ]; then + echo >&2 "beads: invalid BEADS_HOOK_TIMEOUT; using 300 seconds" + _bd_timeout=300 + fi + _bd_timeout_backend=none + _bd_timeout_command= + for _bd_timeout_candidate in timeout gtimeout; do + if command -v "$_bd_timeout_candidate" >/dev/null 2>&1; then + if _bd_timeout_version="$("$_bd_timeout_candidate" --version 2>/dev/null)"; then + case "$_bd_timeout_version" in + "timeout (GNU coreutils) "*) _bd_timeout_command=$_bd_timeout_candidate; break ;; + esac + fi + fi + done + if [ -n "$_bd_timeout_command" ]; then + _bd_timeout_backend=coreutils + if "$_bd_timeout_command" -- "$_bd_timeout" bd hooks run pre-push "$@"; then _bd_exit=0 + else + _bd_exit=$? + fi + elif command -v perl >/dev/null 2>&1; then + _bd_timeout_backend=perl + if perl -e 'alarm shift; exec @ARGV' -- "$_bd_timeout" bd hooks run pre-push "$@"; then + _bd_exit=0 + else + _bd_exit=$? fi else - bd hooks run pre-push "$@" - _bd_exit=$? + echo >&2 "beads: hook 'pre-push' running without timeout; install coreutils or perl to enable BEADS_HOOK_TIMEOUT" + if bd hooks run pre-push "$@"; then + _bd_exit=0 + else + _bd_exit=$? + fi fi - if [ $_bd_exit -eq 3 ]; then + if { [ "$_bd_timeout_backend" = coreutils ] && [ "$_bd_exit" -eq 124 ]; } || { [ "$_bd_timeout_backend" = perl ] && [ "$_bd_exit" -eq 142 ]; }; then + echo >&2 "beads: hook 'pre-push' timed out after ${_bd_timeout}s — continuing without beads" + _bd_exit=0 + fi + if [ "$_bd_exit" -eq 3 ]; then echo >&2 "beads: database not initialized — skipping hook 'pre-push'" _bd_exit=0 fi - if [ $_bd_exit -ne 0 ]; then exit $_bd_exit; fi + if [ "$_bd_exit" -ne 0 ]; then exit "$_bd_exit"; fi fi -# --- END BEADS INTEGRATION v1.0.3 --- +# --- END BEADS INTEGRATION v1.3.2 --- diff --git a/.beads/hooks/prepare-commit-msg b/.beads/hooks/prepare-commit-msg index f0aec3c..6c9e95b 100755 --- a/.beads/hooks/prepare-commit-msg +++ b/.beads/hooks/prepare-commit-msg @@ -1,24 +1,59 @@ #!/usr/bin/env sh -# --- BEGIN BEADS INTEGRATION v1.0.3 --- +# --- BEGIN BEADS INTEGRATION v1.3.2 --- # This section is managed by beads. Do not remove these markers. if command -v bd >/dev/null 2>&1; then export BD_GIT_HOOK=1 _bd_timeout=${BEADS_HOOK_TIMEOUT:-300} - if command -v timeout >/dev/null 2>&1; then - timeout "$_bd_timeout" bd hooks run prepare-commit-msg "$@" - _bd_exit=$? - if [ $_bd_exit -eq 124 ]; then - echo >&2 "beads: hook 'prepare-commit-msg' timed out after ${_bd_timeout}s — continuing without beads" + case "$_bd_timeout" in + *[!0-9]*|'') _bd_timeout_invalid=1 ;; + *[1-9]*) _bd_timeout_invalid=0 ;; + *) _bd_timeout_invalid=1 ;; + esac + if [ "$_bd_timeout_invalid" -eq 1 ]; then + echo >&2 "beads: invalid BEADS_HOOK_TIMEOUT; using 300 seconds" + _bd_timeout=300 + fi + _bd_timeout_backend=none + _bd_timeout_command= + for _bd_timeout_candidate in timeout gtimeout; do + if command -v "$_bd_timeout_candidate" >/dev/null 2>&1; then + if _bd_timeout_version="$("$_bd_timeout_candidate" --version 2>/dev/null)"; then + case "$_bd_timeout_version" in + "timeout (GNU coreutils) "*) _bd_timeout_command=$_bd_timeout_candidate; break ;; + esac + fi + fi + done + if [ -n "$_bd_timeout_command" ]; then + _bd_timeout_backend=coreutils + if "$_bd_timeout_command" -- "$_bd_timeout" bd hooks run prepare-commit-msg "$@"; then _bd_exit=0 + else + _bd_exit=$? + fi + elif command -v perl >/dev/null 2>&1; then + _bd_timeout_backend=perl + if perl -e 'alarm shift; exec @ARGV' -- "$_bd_timeout" bd hooks run prepare-commit-msg "$@"; then + _bd_exit=0 + else + _bd_exit=$? fi else - bd hooks run prepare-commit-msg "$@" - _bd_exit=$? + echo >&2 "beads: hook 'prepare-commit-msg' running without timeout; install coreutils or perl to enable BEADS_HOOK_TIMEOUT" + if bd hooks run prepare-commit-msg "$@"; then + _bd_exit=0 + else + _bd_exit=$? + fi fi - if [ $_bd_exit -eq 3 ]; then + if { [ "$_bd_timeout_backend" = coreutils ] && [ "$_bd_exit" -eq 124 ]; } || { [ "$_bd_timeout_backend" = perl ] && [ "$_bd_exit" -eq 142 ]; }; then + echo >&2 "beads: hook 'prepare-commit-msg' timed out after ${_bd_timeout}s — continuing without beads" + _bd_exit=0 + fi + if [ "$_bd_exit" -eq 3 ]; then echo >&2 "beads: database not initialized — skipping hook 'prepare-commit-msg'" _bd_exit=0 fi - if [ $_bd_exit -ne 0 ]; then exit $_bd_exit; fi + if [ "$_bd_exit" -ne 0 ]; then exit "$_bd_exit"; fi fi -# --- END BEADS INTEGRATION v1.0.3 --- +# --- END BEADS INTEGRATION v1.3.2 --- diff --git a/hosts/common/default.nix b/hosts/common/default.nix index 8a6021d..8eebf0f 100644 --- a/hosts/common/default.nix +++ b/hosts/common/default.nix @@ -49,6 +49,8 @@ # with allowUnfree). Do NOT flatten to top-level attrs — see # overlays/default.nix. inputs.llm-agents.overlays.shared-nixpkgs + # Wraps pkgs.llm-agents.t3code* with the agents' m3ta-chiron identity. + outputs.overlays.t3code-agent-identity # You can also add overlays exported from other flakes: # neovim-nightly-overlay.overlays.default diff --git a/hosts/m3-hermes/secrets.nix b/hosts/m3-hermes/secrets.nix index 9a3b8d2..156d399 100644 --- a/hosts/m3-hermes/secrets.nix +++ b/hosts/m3-hermes/secrets.nix @@ -1,6 +1,10 @@ { age = { secrets = { + hermes-gitea-token = { + file = ../../secrets/hermes-gitea-token.age; + owner = "m3tam3re"; + }; hermes-env = { file = ../../secrets/hermes-env.age; }; diff --git a/hosts/m3-hermes/services/t3code.nix b/hosts/m3-hermes/services/t3code.nix index 32246fd..c4915ba 100644 --- a/hosts/m3-hermes/services/t3code.nix +++ b/hosts/m3-hermes/services/t3code.nix @@ -16,12 +16,14 @@ # so no deploy token) into ~/.agents/skills + ~/.config/opencode/*. A # path unit mirrors skills into ~/.claude/skills for Claude Code # (port of m3ta-home profiles/sets/coding/agents/claude-skills.nix). -# - Git identity: every harness spawned by `t3 serve` commits as the -# m3ta-chiron bot account — via service env vars, deliberately NOT via -# ~/.gitconfig, so m3tam3re's interactive git on this host is untouched. +# - Git identity and Gitea push auth: m3ta-chiron for every harness spawned +# by T3, baked into the package (overlays/default.nix, +# t3code-agent-identity), so m3tam3re's interactive git is untouched. # - Gitea SSH: m3tam3re's ssh config pins User gitea + key ~/.ssh/gitea -# (one-time keygen; pubkey added to the m3ta-chiron account) — covers -# git remotes AND git+ssh:// flake inputs. Host key pinned system-wide. +# (one-time keygen; pubkey added to the m3ta-chiron account) for +# interactive use and git+ssh:// flake inputs. Host key pinned system-wide. +# - Gitea change requests: tea with the hermes-gitea-token agenix secret, +# baked into the same package. # # One-time interactive steps after deploy (deliberately NOT declarative — # subscription auth must live in each harness's own credential store and @@ -53,16 +55,6 @@ cockpitUser = "m3tam3re"; cockpitHome = "/home/${cockpitUser}"; - # Commit identity of the T3 Code agents: the fleet bot account. Env - # vars are respected by git in every process the service spawns; they - # survive restarts and stay out of m3tam3re's dotfiles. - gitIdentityEnv = { - GIT_AUTHOR_NAME = "m3ta-chiron"; - GIT_AUTHOR_EMAIL = "m3ta-chiron@agentmail.to"; - GIT_COMMITTER_NAME = "m3ta-chiron"; - GIT_COMMITTER_EMAIL = "m3ta-chiron@agentmail.to"; - }; - # SSH to the private Gitea for the T3 lane. Sits in m3tam3re's ssh # config (per-user — Hermes' own gitea access via its own ssh config # is unaffected). URL-embedded users (gitea@code.m3ta.dev) match the @@ -115,6 +107,7 @@ in { pkgs.llm-agents.t3code pkgs.llm-agents.opencode2 pkgs.llm-agents.claude-code + pkgs.llm-agents.beads pkgs.agent-lib ]; @@ -134,25 +127,21 @@ in { RestartSec = "5"; }; - environment = - { - T3CODE_PORT = toString port; - # Deterministic service context: HOME explicit so ssh/git resolve - # ~ in every process this service spawns, however deep t3's - # pty/sandbox chain resets the environment. - HOME = cockpitHome; - # Independent of HOME entirely: git uses exactly this ssh config - # (absolute store path) for every gitea remote. - GIT_SSH_COMMAND = "ssh -F ${t3SshConfig}"; - } - // gitIdentityEnv; + environment = { + T3CODE_PORT = toString port; + # Deterministic service context: HOME explicit so tools resolve ~ in + # every process this service spawns, however deep t3's pty/sandbox + # chain resets the environment. + HOME = cockpitHome; + }; - # Harness CLIs and git for the agents T3 Code spawns. + # Harness CLIs, git and the issue tracker for the agents T3 Code spawns. path = with pkgs; [ git openssh llm-agents.opencode2 llm-agents.claude-code + llm-agents.beads ]; }; @@ -171,6 +160,8 @@ in { systemd.tmpfiles.rules = [ "d ${cockpitHome}/.ssh 0700 ${cockpitUser} users -" "L+ ${cockpitHome}/.ssh/config - - - - ${t3SshConfig}" + # The fleet-wide key path the T3 package expects (see t3code-agent-identity). + "L+ ${cockpitHome}/.ssh/m3ta-chiron - - - - ${cockpitHome}/.ssh/gitea" ]; # ── agent-lib v2 client: skills/commands/agents for the harnesses ──── diff --git a/hosts/m3-kratos/secrets.nix b/hosts/m3-kratos/secrets.nix index 0ee16ad..3a580ff 100644 --- a/hosts/m3-kratos/secrets.nix +++ b/hosts/m3-kratos/secrets.nix @@ -1,6 +1,10 @@ { age = { secrets = { + hermes-gitea-token = { + file = ../../secrets/hermes-gitea-token.age; + owner = "m3tam3re"; + }; anytype-key = { file = ../../secrets/anytype-key.age; owner = "m3tam3re"; diff --git a/overlays/default.nix b/overlays/default.nix index df5e9c4..cba45fd 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -74,6 +74,97 @@ opencode-desktop = final.llm-agents.opencode2-desktop; }; + # T3 Code agents act as the m3ta-chiron bot on every host. Baked into the + # T3 packages rather than a session or service: everything T3 spawns + # inherits it, however T3 was launched (desktop launcher, systemd, shell), + # and any host installing T3 gets it. Must come AFTER shared-nixpkgs. + # + # Push auth needs ~/.ssh/m3ta-chiron on each host, with its pubkey on the + # m3ta-chiron Gitea account. A missing key fails the push instead of falling + # back to a personal key. Other hosts keep the user's own ssh config. + # + # Change requests need the agenix secret hermes-gitea-token on each host, + # owned by the T3 user. Without it T3 cannot recognize code.m3ta.dev as Gitea. + t3code-agent-identity = final: prev: let + identity = { + name = "m3ta-chiron"; + email = "m3ta-chiron@agentmail.to"; + }; + + giteaKnownHosts = final.writeText "gitea-known-hosts" '' + code.m3ta.dev ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFmmqZ4GgDEXJgj8uYrZAr/EoLIA6LJGkTIyKGQD/60a + ''; + + # ssh expands ~ from passwd, so this does not depend on $HOME. + sshConfig = final.writeText "t3-agent-ssh-config" '' + Host code.m3ta.dev + User gitea + IdentityFile ~/.ssh/m3ta-chiron + IdentitiesOnly yes + UserKnownHostsFile ${giteaKnownHosts} + + # Conditional: IdentityFile accumulates across matching blocks, so a + # personal code.m3ta.dev entry must not be read for this host. + Host * !code.m3ta.dev + Include ~/.ssh/config + ''; + + # T3 only recognizes a Gitea on a custom domain through a matching tea + # login. The config lives in a private temp dir per call, so the token stays + # out of the nix store and a personal ~/.config/tea is left alone. + giteaTokenFile = "/run/agenix/hermes-gitea-token"; + agentTea = final.writeShellApplication { + name = "tea"; + text = '' + config="$(${final.coreutils}/bin/mktemp -d)" + trap '${final.coreutils}/bin/rm -rf "$config"' EXIT + ${final.coreutils}/bin/mkdir "$config/tea" + if [ -r ${giteaTokenFile} ]; then + ${final.coreutils}/bin/cat > "$config/tea/config.yml" <