From 478311f913763fedf01fbe05d34f30fcbb6e3049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9C=BF=20corey?= Date: Mon, 9 Mar 2026 19:32:54 -0700 Subject: [PATCH 1/3] fix(glyph): parallelize mcpjungle server registration The mcpjungle-register oneshot service registered 9 servers sequentially, each polling up to 60s for availability. This blocked nixos-rebuild switch for up to 9 minutes in the worst case. Run each registration in a background subshell so all servers are polled concurrently, reducing worst-case wait to 60s. Co-Authored-By: Claude Opus 4.6 --- modules/nixos/llm/mcpjungle.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/nixos/llm/mcpjungle.nix b/modules/nixos/llm/mcpjungle.nix index a14815a..11b4ffa 100644 --- a/modules/nixos/llm/mcpjungle.nix +++ b/modules/nixos/llm/mcpjungle.nix @@ -150,9 +150,16 @@ in { fi ''; - registrations = lib.concatStringsSep "\n" (lib.mapAttrsToList mkRegistration cfg.servers); + mkBackgroundRegistration = name: server: '' + ( + ${mkRegistration name server} + ) & + ''; + + registrations = lib.concatStringsSep "\n" (lib.mapAttrsToList mkBackgroundRegistration cfg.servers); in '' ${registrations} + wait ''; }; From ce70bd292ee97feac1b247da55b024d5cb37e440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9C=BF=20corey?= Date: Mon, 9 Mar 2026 20:05:23 -0700 Subject: [PATCH 2/3] fix(glyph): prevent mcpjungle-register from blocking rebuild The mcpjungle-register oneshot service was in multi-user.target, causing nixos-rebuild switch to block until all 9 MCP servers were polled and registered (up to 60s even with parallel registration). Replace the direct wantedBy with a systemd timer that fires 5s after activation. The timer start/restart is instant so activation never blocks. The timer has restartTriggers based on the server config hash, so adding/removing servers re-triggers registration. The service itself has restartIfChanged = false to prevent NixOS from directly restarting (and blocking on) the oneshot during activation. Also parallelizes registrations within the script and removes RemainAfterExit since the timer handles re-triggering. Co-Authored-By: Claude Opus 4.6 --- modules/nixos/llm/mcpjungle.nix | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/nixos/llm/mcpjungle.nix b/modules/nixos/llm/mcpjungle.nix index 11b4ffa..9a6b918 100644 --- a/modules/nixos/llm/mcpjungle.nix +++ b/modules/nixos/llm/mcpjungle.nix @@ -87,14 +87,24 @@ in { }; }; + systemd.timers.mcpjungle-register = lib.mkIf (cfg.servers != {}) { + description = "Trigger MCP server registration"; + wantedBy = ["timers.target"]; + # Re-trigger when server configuration changes + restartTriggers = [(builtins.hashString "sha256" (builtins.toJSON cfg.servers))]; + timerConfig = { + OnActiveSec = "5s"; + }; + }; + systemd.services.mcpjungle-register = lib.mkIf (cfg.servers != {}) { description = "Register MCP servers with MCPJungle"; after = ["mcpjungle.service"]; requires = ["mcpjungle.service"]; - wantedBy = ["multi-user.target"]; + # Prevent NixOS activation from blocking on this oneshot + restartIfChanged = false; serviceConfig = { Type = "oneshot"; - RemainAfterExit = true; }; path = [pkgs.curl pkgs.envsubst]; script = let From af649b73d6fff126ef610b9b2b4a3cfc4e044819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9C=BF=20corey?= Date: Mon, 9 Mar 2026 20:17:06 -0700 Subject: [PATCH 3/3] fix(glyph): use Type=simple so registration never blocks activation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Type=oneshot causes systemctl start to block until the script completes. Changing to Type=simple makes systemctl start return immediately — the registration script still runs to completion in the background. Co-Authored-By: Claude Opus 4.6 --- modules/nixos/llm/mcpjungle.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nixos/llm/mcpjungle.nix b/modules/nixos/llm/mcpjungle.nix index 9a6b918..1441c13 100644 --- a/modules/nixos/llm/mcpjungle.nix +++ b/modules/nixos/llm/mcpjungle.nix @@ -104,7 +104,7 @@ in { # Prevent NixOS activation from blocking on this oneshot restartIfChanged = false; serviceConfig = { - Type = "oneshot"; + Type = "simple"; }; path = [pkgs.curl pkgs.envsubst]; script = let