Compare commits

...
Author SHA1 Message Date
m3ta-chironandClaude Fable 5.1 c9f68a4361 feat(coding/agents): hand the shared MCP catalogue to Claude Code
- Move programs.mcp.servers out of agents.nix into mcp.nix so hosts that
  do not load the whole coding set (T3 Code servers) can import it alone
- Add claude-code.nix: programs.claude-code with enableMcpIntegration,
  replacing the bare llm-agents.claude-code package (would collide on
  bin/claude). home-manager delivers the catalogue as a generated plugin,
  ~/.claude/settings.json and ~/.claude.json stay writable
- ai-memory: register the session-aware Claude bridge via
  programs.claude-code.mcpServers instead of `ai-memory install-mcp`;
  activation only removes the stale user-scope entry now
- Adjust ai-memory.test.sh accordingly

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-10 20:15:24 +01:00
m3ta-chiron b63db50485 Merge branch 'master' of code.m3ta.dev:m3tam3re/m3ta-home 2026-11-05 07:59:10 +01:00
m3ta-chiron 11ddf5e00c Merge branch 'feat/t3code-environment-file' 2026-11-05 07:58:22 +01:00
m3ta-chironandClaude Opus 5.5 2187d9263d feat(t3code): add environmentFile option
Loads an optional KEY=value file (e.g. an agenix secret) as the
service's systemd EnvironmentFile. Store paths are rejected so secrets
cannot end up in the Nix store.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 07:48:18 +01:00
m3ta-chiron 4e46e08e4d Merge pull request 'fix(nushell): keep loadSessionVariables off explicitly' (#8) from fix/nushell-session-variables into master 2026-11-03 18:09:08 +01:00
m3ta-chironandClaude Opus 5.5 0c509a7c90 fix(nushell): keep loadSessionVariables off explicitly
home-manager changed the default to true for stateVersion 26.11 and warns
on every host evaluation. Setting the legacy value keeps nushell's
behaviour and silences the warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 18:09:00 +01:00
m3ta-chiron 38d53d68c0 Merge pull request 'revert: fix(nushell): set loadSessionVariables explicitly' (#7) from revert/nushell-session-variables into master 2026-11-03 16:20:03 +01:00
m3ta-chironandClaude Opus 5.5 6f1826b96b revert: fix(nushell): set loadSessionVariables explicitly
nixos-config's home-manager pin predates the option, so every host failed
to evaluate. Set it again once that pin moves past the default change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 16:19:57 +01:00
8 changed files with 117 additions and 54 deletions

No files matched your search

@@ -35,6 +35,7 @@ Agents committen auf beiden Hosts als `m3ta-chiron`.
| `m3ta.t3code.port` | port | `3773` | | `m3ta.t3code.port` | port | `3773` |
| `m3ta.t3code.interface` | str | `"wt0"` | | `m3ta.t3code.interface` | str | `"wt0"` |
| `m3ta.t3code.package` | package | `pkgs.llm-agents.t3code` | | `m3ta.t3code.package` | package | `pkgs.llm-agents.t3code` |
| `m3ta.t3code.environmentFile` | null oder absoluter Pfad außerhalb des Stores | `null` |
Eine Assertion verlangt `services.netbird.enable = true`. Eine Assertion verlangt `services.netbird.enable = true`.
@@ -42,6 +43,7 @@ Eine Assertion verlangt `services.netbird.enable = true`.
- Läuft als `user` mit Gruppe `users`; `HOME` und `WorkingDirectory` kommen aus `config.users.users.<user>.home`. - Läuft als `user` mit Gruppe `users`; `HOME` und `WorkingDirectory` kommen aus `config.users.users.<user>.home`.
- `T3CODE_PORT` kommt aus `port`. - `T3CODE_PORT` kommt aus `port`.
- `environmentFile` wird, falls gesetzt, als `EnvironmentFile` geladen (`KEY=value`-Zeilen, z. B. ein agenix-Secret).
- `path` enthält `/etc/profiles/per-user/<user>` und `/run/current-system/sw`. - `path` enthält `/etc/profiles/per-user/<user>` und `/run/current-system/sw`.
- `Restart = "on-failure"`, `RestartSec = 5`. - `Restart = "on-failure"`, `RestartSec = 5`.
- `bindsTo`, `after` und `wantedBy` zeigen auf `sys-subsystem-net-devices-<interface>.device`. - `bindsTo`, `after` und `wantedBy` zeigen auf `sys-subsystem-net-devices-<interface>.device`.
+15
View File
@@ -52,6 +52,20 @@ in {
defaultText = lib.literalExpression "pkgs.llm-agents.t3code"; defaultText = lib.literalExpression "pkgs.llm-agents.t3code";
description = "T3 Code package."; description = "T3 Code package.";
}; };
environmentFile = lib.mkOption {
type = lib.types.nullOr (lib.types.pathWith {
inStore = false;
absolute = true;
});
default = null;
example = "/run/agenix/t3code-env";
description = ''
File with `KEY=value` lines loaded into the server's environment
(systemd `EnvironmentFile`), e.g. tokens for the harnesses. Keep it
outside the Nix store, for example as an agenix secret.
'';
};
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
@@ -75,6 +89,7 @@ in {
ExecStart = "${serve}/bin/t3code-serve ${cfg.interface} ${cfg.package}/bin/t3"; ExecStart = "${serve}/bin/t3code-serve ${cfg.interface} ${cfg.package}/bin/t3";
Restart = "on-failure"; Restart = "on-failure";
RestartSec = "5"; RestartSec = "5";
EnvironmentFile = lib.mkIf (cfg.environmentFile != null) cfg.environmentFile;
}; };
environment = { environment = {
+3 -2
View File
@@ -15,8 +15,9 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.nushell = { programs.nushell = {
enable = true; enable = true;
# Explicit to silence the home-manager default-change warning. # Keep the pre-26.11 behaviour; set explicitly to silence the
loadSessionVariables = true; # home-manager default-change warning.
loadSessionVariables = false;
envFile.text = '' envFile.text = ''
$env.config.show_banner = false $env.config.show_banner = false
$env.NIX_PATH = "nixpkgs=channel:nixos-unstable" $env.NIX_PATH = "nixpkgs=channel:nixos-unstable"
+4 -40
View File
@@ -18,50 +18,15 @@
}; };
imports = [ imports = [
# ai-memory client, skill mirror and OpenCode config # ai-memory client, skill mirror, shared MCP catalogue, OpenCode and
# Claude Code config
./ai-memory.nix ./ai-memory.nix
./claude-skills.nix ./claude-skills.nix
./mcp.nix
./opencode.nix ./opencode.nix
./claude-code.nix
]; ];
programs.mcp = {
enable = true;
servers = {
ContextMode = {
command = "bash";
args = ["-c" "exec bunx context-mode@latest"];
};
DeepWiki = {
url = "https://mcp.deepwiki.com/mcp";
};
Exa = {
command = "bash";
args = ["-c" "EXA_API_KEY=$(cat /run/agenix/exa-key) exec bunx exa-mcp-server@latest tools=web_search_exa"];
};
SallyAI = {
url = "https://app.sally.io/api/v1/McpExternal";
};
Metabase = {
url = "https://kpi.az-gruppe.com/api/metabase-mcp";
};
Outline = {
url = "https://wiki.az-gruppe.com/mcp";
};
Playwright = {
command = "bash";
args = ["-c" "exec bunx @playwright/mcp@latest"];
};
Ref = {
command = "bash";
args = ["-c" "REF_API_KEY=$(cat /run/agenix/ref-key) exec bunx ref-tools-mcp@latest"];
};
Teams = {
command = "bunx";
args = ["-y" "@floriscornel/teams-mcp@latest"];
};
};
};
# NOTE: llm-agent packages are consumed via the `llm-agents` namespace # NOTE: llm-agent packages are consumed via the `llm-agents` namespace
# (pkgs.llm-agents.*), provided by numtide/llm-agents.nix's # (pkgs.llm-agents.*), provided by numtide/llm-agents.nix's
# `overlays.shared-nixpkgs`. The consumer's nixos-config MUST apply that # `overlays.shared-nixpkgs`. The consumer's nixos-config MUST apply that
@@ -72,7 +37,6 @@
agent-lib agent-lib
llm-agents.agent-browser llm-agents.agent-browser
llm-agents.beads llm-agents.beads
llm-agents.claude-code
llm-agents.claude-desktop llm-agents.claude-desktop
crunch crunch
docker-sbx docker-sbx
+21 -11
View File
@@ -3,12 +3,13 @@
# The server runs on m3-hermes (nixos-config) and is reached at # The server runs on m3-hermes (nixos-config) and is reached at
# memory.m3ta.dev; no server runs on clients. Hybrid setup: # memory.m3ta.dev; no server runs on clients. Hybrid setup:
# - Nix owns the package, the client config (server URL + bearer token # - Nix owns the package, the client config (server URL + bearer token
# file), the OpenCode MCP entry (via programs.mcp, since opencode.json # file), the MCP entries (programs.mcp for OpenCode, and a session-aware
# is a home-manager symlink) and the scope markers (~/.ai-memory.toml # override in programs.claude-code.mcpServers for Claude Code, both
# plus one marker per workspace directory). # delivered through the agents' enableMcpIntegration) and the scope
# - Activation runs ai-memory's own installers for the lifecycle hooks, # markers (~/.ai-memory.toml plus one marker per workspace directory).
# the session-aware Claude Code MCP entry and the skills, so generated # - Activation runs ai-memory's own installers for the lifecycle hooks and
# files always match the installed ai-memory version. # the skills, so generated files always match the installed ai-memory
# version.
# #
# The bearer token (an `aim_` API key, one per host) is an agenix secret the # The bearer token (an `aim_` API key, one per host) is an agenix secret the
# host repo provides at `tokenFile`. It is never copied into a generated # host repo provides at `tokenFile`. It is never copied into a generated
@@ -100,6 +101,18 @@ in {
args = ["mcp-bridge" "--no-session-id" "--server-url" "${cfg.serverUrl}/mcp"]; args = ["mcp-bridge" "--no-session-id" "--server-url" "${cfg.serverUrl}/mcp"];
}; };
# Claude Code gets the same server name through
# programs.claude-code.enableMcpIntegration, but session-aware: the stdio
# bridge forwards the lifecycle-hook session id and reads the token file
# itself. (A plain HTTP entry carries no credentials, and Claude Code then
# tries OAuth client registration, which ai-memory does not offer.)
# Claude Code's own mcpServers take precedence over the shared entry, so
# this is one server, not two.
programs.claude-code.mcpServers.ai-memory = mkIf (elem "claude-code" cfg.agents) {
command = exe;
args = ["mcp-bridge" "--server-url" "${cfg.serverUrl}/mcp"];
};
home.file = home.file =
{ {
# Client config: `ai-memory hook`, `mcp-bridge` and the installers # Client config: `ai-memory hook`, `mcp-bridge` and the installers
@@ -130,13 +143,10 @@ in {
'') '')
cfg.agents} cfg.agents}
${optionalString (elem "claude-code" cfg.agents) '' ${optionalString (elem "claude-code" cfg.agents) ''
# The MCP entry now comes from programs.claude-code (see above);
# drop the user-scope entry earlier versions wrote into ~/.claude.json.
export PATH="${pkgs.llm-agents.claude-code}/bin:$PATH" export PATH="${pkgs.llm-agents.claude-code}/bin:$PATH"
run claude mcp remove ai-memory -s user >/dev/null 2>&1 || true run claude mcp remove ai-memory -s user >/dev/null 2>&1 || true
# --session-aware: stdio bridge that reads the token file itself. A
# plain HTTP entry carries no credentials, and Claude Code then tries
# OAuth client registration, which ai-memory does not offer.
run ${exe} install-mcp --client claude-code --apply --session-aware \
--server-url ${escapeShellArg "${cfg.serverUrl}/mcp"}
''} ''}
# Into ~/.agents/skills; claude-skills-sync mirrors them to Claude. # Into ~/.agents/skills; claude-skills-sync mirrors them to Claude.
run ${exe} install-skills --scope global --agent agents run ${exe} install-skills --scope global --agent agents
@@ -51,7 +51,12 @@ check "hooks opencode2" "$act" "install-hooks --agent opencode2 --apply"
check "auth-token symlink" "$act" "ln -sfn /run/agenix/ai-memory-token " check "auth-token symlink" "$act" "ln -sfn /run/agenix/ai-memory-token "
refute "no token on command lines" "$act" "--auth-token" refute "no token on command lines" "$act" "--auth-token"
refute "activation must not write opencode.json (home-manager symlink)" "$act" "install-mcp --client opencode" refute "activation must not write opencode.json (home-manager symlink)" "$act" "install-mcp --client opencode"
check "claude mcp is the session-aware bridge" "$act" "install-mcp --client claude-code --apply --session-aware" refute "activation no longer registers the claude mcp itself" "$act" "install-mcp --client claude-code"
check "stale user-scope claude entry is removed" "$act" "claude mcp remove ai-memory -s user"
claude="$(ev programs.claude-code.mcpServers.ai-memory.args --apply 'builtins.concatStringsSep " "')"
check "claude mcp is the session-aware bridge" "$claude" "mcp-bridge --server-url https://memory.m3ta.dev/mcp"
refute "claude mcp forwards the session id" "$claude" "--no-session-id"
# Missing token file: skip with a warning, exit 0, never call ai-memory. # Missing token file: skip with a warning, exit 0, never call ai-memory.
script="$(printf '%s\n' "$act" | sed 's|/run/agenix/ai-memory-token|/nonexistent/ai-memory-token|g')" script="$(printf '%s\n' "$act" | sed 's|/run/agenix/ai-memory-token|/nonexistent/ai-memory-token|g')"
@@ -0,0 +1,20 @@
# Claude Code via home-manager `programs.claude-code`.
#
# enableMcpIntegration hands the shared programs.mcp catalogue (mcp.nix) to
# Claude Code the same way opencode.nix does for OpenCode: home-manager
# generates a plugin carrying .mcp.json and registers it (as a personal plugin
# under ~/.claude/skills/claude-code-home-manager on home-manager master, via a
# `--plugin-dir` wrapper on release-26.05). Nothing in ~/.claude is turned
# into a store symlink: settings.json (ai-memory hooks, plugins, theme) and
# ~/.claude.json (logins) stay writable for Claude Code itself.
#
# Do NOT add llm-agents.claude-code to home.packages next to this module;
# programs.claude-code installs its (possibly wrapped) package and a second
# `claude` would collide in the profile.
{pkgs, ...}: {
programs.claude-code = {
enable = true;
package = pkgs.llm-agents.claude-code;
enableMcpIntegration = true;
};
}
+46
View File
@@ -0,0 +1,46 @@
# Shared MCP server catalogue (home-manager `programs.mcp`).
#
# Single source for every agent that integrates with programs.mcp:
# OpenCode (opencode.nix, enableMcpIntegration) and Claude Code
# (claude-code.nix, enableMcpIntegration). ai-memory adds its own entry in
# ai-memory.nix. Hosts that do not load the whole coding set (servers running
# T3 Code) import this file directly.
{...}: {
programs.mcp = {
enable = true;
servers = {
ContextMode = {
command = "bash";
args = ["-c" "exec bunx context-mode@latest"];
};
DeepWiki = {
url = "https://mcp.deepwiki.com/mcp";
};
Exa = {
command = "bash";
args = ["-c" "EXA_API_KEY=$(cat /run/agenix/exa-key) exec bunx exa-mcp-server@latest tools=web_search_exa"];
};
SallyAI = {
url = "https://app.sally.io/api/v1/McpExternal";
};
Metabase = {
url = "https://kpi.az-gruppe.com/api/metabase-mcp";
};
Outline = {
url = "https://wiki.az-gruppe.com/mcp";
};
Playwright = {
command = "bash";
args = ["-c" "exec bunx @playwright/mcp@latest"];
};
Ref = {
command = "bash";
args = ["-c" "REF_API_KEY=$(cat /run/agenix/ref-key) exec bunx ref-tools-mcp@latest"];
};
Teams = {
command = "bunx";
args = ["-y" "@floriscornel/teams-mcp@latest"];
};
};
};
}