From aef9d84d611df5a40c7bb60b45d96367e82fe11d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20K=C3=B6nig?= Date: Mon, 2 Nov 2026 08:02:07 +0100 Subject: [PATCH] refactor(m3-kratos): use the T3 Code module from m3ta-home Co-Authored-By: Claude Opus 5.5 --- hosts/common/default.nix | 3 +- hosts/m3-kratos/services/t3code.nix | 44 ++------------ overlays/default.nix | 91 ----------------------------- 3 files changed, 7 insertions(+), 131 deletions(-) diff --git a/hosts/common/default.nix b/hosts/common/default.nix index 8eebf0f..4efc92e 100644 --- a/hosts/common/default.nix +++ b/hosts/common/default.nix @@ -13,6 +13,7 @@ ./ports.nix ./users inputs.home-manager.nixosModules.home-manager + inputs.m3ta-home.nixosModules.t3code ]; environment.pathsToLink = ["/share/xdg-desktop-portal" "/share/applications"]; @@ -50,7 +51,7 @@ # 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 + inputs.m3ta-home.overlays.t3code-agent-identity # You can also add overlays exported from other flakes: # neovim-nightly-overlay.overlays.default diff --git a/hosts/m3-kratos/services/t3code.nix b/hosts/m3-kratos/services/t3code.nix index 4036cff..d954ce4 100644 --- a/hosts/m3-kratos/services/t3code.nix +++ b/hosts/m3-kratos/services/t3code.nix @@ -1,41 +1,7 @@ -{ - config, - pkgs, - ... -}: let - port = config.m3ta.ports.get "t3code"; - cockpitUser = "m3tam3re"; - netbirdIp = "100.81.73.194"; -in { - # T3 Code server: reachable from NetBird mesh peers only. It owns ~/.t3, so - # the desktop app must connect as a client with its local environment off. - systemd.services.t3code = { - description = "T3 Code server"; - # Binding fails until NetBird has assigned the address; Restart retries. - after = ["netbird.service"]; - wants = ["netbird.service"]; - wantedBy = ["multi-user.target"]; - - serviceConfig = { - User = cockpitUser; - Group = "users"; - WorkingDirectory = "/home/${cockpitUser}"; - ExecStart = "${pkgs.llm-agents.t3code}/bin/t3 serve --host ${netbirdIp}"; - Restart = "on-failure"; - RestartSec = "5"; - }; - - environment = { - T3CODE_PORT = toString port; - HOME = "/home/${cockpitUser}"; - }; - - # The harnesses come from the user's profile, not from the service. - path = [ - "/etc/profiles/per-user/${cockpitUser}" - "/run/current-system/sw" - ]; +{config, ...}: { + m3ta.t3code = { + enable = true; + user = "m3tam3re"; + port = config.m3ta.ports.get "t3code"; }; - - networking.firewall.interfaces.wt0.allowedTCPPorts = [port]; } diff --git a/overlays/default.nix b/overlays/default.nix index cba45fd..df5e9c4 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -74,97 +74,6 @@ 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" <