diff --git a/flake.lock b/flake.lock index 38d7dcb2ab..c1a98bab54 100644 --- a/flake.lock +++ b/flake.lock @@ -667,6 +667,42 @@ "type": "github" } }, + "fleet_2": { + "inputs": { + "nixpkgs": "nixpkgs_17" + }, + "locked": { + "lastModified": 1793665075, + "narHash": "sha256-xa5Wy5Y+Oag+7x5iq1SEfoT/8Cp+t9gNItErSr504HM=", + "owner": "dezren39", + "repo": "fleet", + "rev": "082bd9e78bcac374d0b3bec89ec1ee9acd4386d1", + "type": "github" + }, + "original": { + "owner": "dezren39", + "repo": "fleet", + "type": "github" + } + }, + "fleet_3": { + "inputs": { + "nixpkgs": "nixpkgs_18" + }, + "locked": { + "lastModified": 1793665075, + "narHash": "sha256-xa5Wy5Y+Oag+7x5iq1SEfoT/8Cp+t9gNItErSr504HM=", + "owner": "dezren39", + "repo": "fleet", + "rev": "082bd9e78bcac374d0b3bec89ec1ee9acd4386d1", + "type": "github" + }, + "original": { + "owner": "dezren39", + "repo": "fleet", + "type": "github" + } + }, "git-hooks": { "inputs": { "flake-compat": [ @@ -1276,6 +1312,22 @@ } }, "mcpx-src": { + "flake": false, + "locked": { + "lastModified": 1793697745, + "narHash": "sha256-qnkwwNhP9WfZdJ4SLjd3oADqrNSPcHMWODMwt/4Hf1w=", + "owner": "developing-today", + "repo": "code", + "rev": "282064c54be3b3542a9eedd0c1a1de99d2968bbf", + "type": "github" + }, + "original": { + "owner": "developing-today", + "repo": "code", + "type": "github" + } + }, + "mcpx-src_2": { "flake": false, "locked": { "lastModified": 1793216845, @@ -1886,48 +1938,48 @@ }, "nixpkgs_17": { "locked": { - "lastModified": 1791594108, - "narHash": "sha256-XK4KceonkwD8LuMAt/vNrz982mXJM5jeHAxMwsUXXAQ=", + "lastModified": 1793645915, + "narHash": "sha256-yRzh4uc8uxFv5+5TROEIH1rUL2FF1/cvfc+uq5JGGHY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6510408d147d8c5e6d76043e899e9251756f6a75", + "rev": "f9887a8a434bfba06e20dfc77bc8e0628266af84", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-unstable", "repo": "nixpkgs", + "rev": "f9887a8a434bfba06e20dfc77bc8e0628266af84", "type": "github" } }, "nixpkgs_18": { "locked": { - "lastModified": 1793166571, - "narHash": "sha256-3+DlA8JY6abKt8G9hoZgTiSNLxdkGTn2a5MeiNDXmIc=", + "lastModified": 1793645915, + "narHash": "sha256-yRzh4uc8uxFv5+5TROEIH1rUL2FF1/cvfc+uq5JGGHY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "fa45202b90a351983649116adb577827b2a9a679", + "rev": "f9887a8a434bfba06e20dfc77bc8e0628266af84", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixpkgs-unstable", "repo": "nixpkgs", + "rev": "f9887a8a434bfba06e20dfc77bc8e0628266af84", "type": "github" } }, "nixpkgs_19": { "locked": { - "lastModified": 1735563628, - "narHash": "sha256-OnSAY7XDSx7CtDoqNh8jwVwh4xNL/2HaJxGjryLWzX8=", + "lastModified": 1793166571, + "narHash": "sha256-3+DlA8JY6abKt8G9hoZgTiSNLxdkGTn2a5MeiNDXmIc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b134951a4c9f3c995fd7be05f3243f8ecd65d798", + "rev": "fa45202b90a351983649116adb577827b2a9a679", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-24.05", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } @@ -1949,6 +2001,22 @@ } }, "nixpkgs_20": { + "locked": { + "lastModified": 1735563628, + "narHash": "sha256-OnSAY7XDSx7CtDoqNh8jwVwh4xNL/2HaJxGjryLWzX8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b134951a4c9f3c995fd7be05f3243f8ecd65d798", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_21": { "locked": { "lastModified": 1790689126, "narHash": "sha256-ilerN1WLSvF+HMjziC/Wv99J5y02maDH+6hZPwsORKg=", @@ -1964,7 +2032,7 @@ "type": "github" } }, - "nixpkgs_21": { + "nixpkgs_22": { "locked": { "lastModified": 1719848872, "narHash": "sha256-H3+EC5cYuq+gQW8y0lSrrDZfH71LB4DAf+TDFyvwCNA=", @@ -1980,7 +2048,7 @@ "type": "github" } }, - "nixpkgs_22": { + "nixpkgs_23": { "locked": { "lastModified": 1769461804, "narHash": "sha256-msG8SU5WsBUfVVa/9RPLaymvi5bI8edTavbIq3vRlhI=", @@ -1996,7 +2064,7 @@ "type": "github" } }, - "nixpkgs_23": { + "nixpkgs_24": { "locked": { "lastModified": 1790769526, "narHash": "sha256-5AIVFLRcx8YAwbFTVPTs7YhwJH7JyHfAQsvXmpovcXI=", @@ -2012,7 +2080,7 @@ "type": "github" } }, - "nixpkgs_24": { + "nixpkgs_25": { "locked": { "lastModified": 1790689126, "narHash": "sha256-ilerN1WLSvF+HMjziC/Wv99J5y02maDH+6hZPwsORKg=", @@ -2207,17 +2275,20 @@ }, "openchamber": { "inputs": { - "nixpkgs": "nixpkgs_17", - "opencode": [ - "opencode" - ] + "fleet": "fleet_2", + "nixpkgs": [ + "openchamber", + "fleet", + "nixpkgs" + ], + "opencode": "opencode" }, "locked": { - "lastModified": 1793284929, - "narHash": "sha256-nIPS1W+TPr+xdR0XHeiFyeEaQNmYsMRwuERt6PLeDdI=", + "lastModified": 1793706172, + "narHash": "sha256-J/jSc+E+Nyw90uyKfApMrPbRACi/Ww8MxcEnQegfH0o=", "owner": "developing-today", "repo": "openchamber", - "rev": "8fc03b7a913be82f82410280a40037804dedfc89", + "rev": "e1ad052118956b95550a0d9a7c3dbc57bc49ed72", "type": "github" }, "original": { @@ -2228,8 +2299,31 @@ }, "opencode": { "inputs": { + "fleet": "fleet_3", "mcpx-src": "mcpx-src", - "nixpkgs": "nixpkgs_18" + "nixpkgs": [ + "openchamber", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1793706001, + "narHash": "sha256-WIhYhS4ImNkk6H+Y5wk0Z4dsCehQ0DvC09FeD+CEM8s=", + "owner": "developing-today", + "repo": "opencode", + "rev": "2d912e02fce34b9e7c39288f045e1cf2b6318fcf", + "type": "github" + }, + "original": { + "owner": "developing-today", + "repo": "opencode", + "type": "github" + } + }, + "opencode_2": { + "inputs": { + "mcpx-src": "mcpx-src_2", + "nixpkgs": "nixpkgs_19" }, "locked": { "lastModified": 1793647881, @@ -2397,7 +2491,7 @@ "omasnap": "omasnap", "omnix": "omnix", "openchamber": "openchamber", - "opencode": "opencode", + "opencode": "opencode_2", "pre-commit-hooks": "pre-commit-hooks_2", "roc": "roc", "server": "server", @@ -2481,7 +2575,7 @@ "server": { "inputs": { "microvm": "microvm_2", - "nixpkgs": "nixpkgs_19" + "nixpkgs": "nixpkgs_20" }, "locked": { "lastModified": 1731735740, @@ -2576,7 +2670,7 @@ }, "ssh-to-age": { "inputs": { - "nixpkgs": "nixpkgs_20" + "nixpkgs": "nixpkgs_21" }, "locked": { "lastModified": 1791089589, @@ -2886,7 +2980,7 @@ "unattended-installer": { "inputs": { "disko": "disko_3", - "nixpkgs": "nixpkgs_21" + "nixpkgs": "nixpkgs_22" }, "locked": { "lastModified": 1724352083, @@ -2905,7 +2999,7 @@ "waybar": { "inputs": { "flake-compat": "flake-compat_5", - "nixpkgs": "nixpkgs_22" + "nixpkgs": "nixpkgs_23" }, "locked": { "lastModified": 1790961154, @@ -2991,7 +3085,7 @@ "yazi": { "inputs": { "flake-utils": "flake-utils_9", - "nixpkgs": "nixpkgs_23", + "nixpkgs": "nixpkgs_24", "rust-overlay": "rust-overlay_2" }, "locked": { @@ -3011,7 +3105,7 @@ "zen-browser": { "inputs": { "home-manager": "home-manager_3", - "nixpkgs": "nixpkgs_24" + "nixpkgs": "nixpkgs_25" }, "locked": { "lastModified": 1791521685, diff --git a/flake.nix b/flake.nix index 74edc2ab41..f013f8a46e 100755 --- a/flake.nix +++ b/flake.nix @@ -266,10 +266,13 @@ rec { opencode = { url = "github:developing-today/opencode"; }; - # OpenChamber, built from its own flake against the opencode input above. + # OpenChamber. Its opencode input deliberately does NOT follow + # this flake's `opencode` above: the service cascade's module + # chain (openchamber -> opencode fork -> mcpx) is governed by + # OpenChamber's own lock file, so the modules and the packages + # they manage always come from the same, upstream-paired pins. openchamber = { url = "github:developing-today/openchamber"; - inputs.opencode.follows = "opencode"; }; # OpenClaw: declarative packaging for the OpenClaw gateway (peer # intelligence source on the laptop). Home Manager module + overlay; diff --git a/home/common/default.nix b/home/common/default.nix index b7d804fddf..b1eefe781c 100644 --- a/home/common/default.nix +++ b/home/common/default.nix @@ -54,9 +54,8 @@ let agent-shell-env = pkgs.callPackage ../../pkgs/agent-shell-env { }; # mcpx MCP gateway and Code Mode execution runner. mcpx = pkgs.callPackage ../../pkgs/mcpx/package.nix { }; - # The environment the mcpx daemon runs with. It is set by the start wrapper - # below rather than by the unit, because `mcpx upgrade` starts the successor - # through that same wrapper, so the successor gets what a fresh start gets. + # The environment the mcpx daemon runs with (services.mcpx.environment + # below; the module renders it into the unit). mcpxEnvironment = { OPENCODE_BINARY = "${inputs.opencode.packages.${system}.opencode}/bin/opencode"; OPENCODE_V2_BIN = "${inputs.opencode.packages.${system}.opencode}/bin/opencode"; @@ -72,121 +71,26 @@ let pkgs.openssh ]; }; - # The unit's start command, ahead of the binary. Its store path changes when - # the environment or the wrapper does, and the activation keys on that. - mcpxStart = pkgs.writeShellScript "mcpx-start" '' - ${lib.concatStrings ( - lib.mapAttrsToList (k: v: "export ${k}=${lib.escapeShellArg v}\n") mcpxEnvironment - )} - exec "$@" - ''; + # The daemon's configuration (the former ~/code/.mcpx.json), and the + # config file the mcpx module renders from it: reproduced here so + # the deploy key below tracks the daemon's real configuration + # without this file needing the module system's `config`. (With an + # empty `servers` the module renders + # settings // { mcpServers = settings.mcpServers; }, so the two + # writeText results are the same store path.) + mcpxSettings = import ./mcpx-settings.nix; + mcpxConfigRendered = pkgs.writeText "mcpx-config.json" (builtins.toJSON mcpxSettings); + # The deploy key for the handover in home.activation.mcpxDeploy + # below: a switch that changes the daemon, its configuration or its + # environment hands the running daemon over, so the key covers + # exactly those three. mcpxKey = deployKey "mcpx" [ mcpx - mcpxStart + mcpxConfigRendered + (builtins.toJSON mcpxEnvironment) ]; - openchamberStart = pkgs.writeShellScript "openchamber-serve" '' - # Single-instance guard (dezren39/nix#1117). The unit below is - # socket-activated with KillMode=process: a stop terminates only the - # tracked main process, so a server that is no longer the tracked - # main -- a self-handoff predecessor systemd has lost track of -- - # survives in the cgroup still holding the listen socket systemd - # handed it. The next start passes the same socket to a new server - # and both accept() on it, so /api/version answers alternate between - # instances. Reap any leftover server before taking the socket over. - # Only the web server is matched (its managed OpenCode serves a - # different port and must stay up for adoption), and this script's - # own pid is excluded -- it execs into the new server below. - leftovers="" - for proc in /proc/[0-9]*; do - pid="''${proc#/proc/}" - [ "$pid" = "$$" ] && continue - # The pattern text itself rides in the argv of anything inspecting - # the fleet (a grep, a diagnostic shell), so a cmdline match alone - # is not proof: the process must actually be the node server. - exe="$(readlink "$proc/exe" 2>/dev/null)" || continue - case "$exe" in - */node | */openchamber) ;; - *) continue ;; - esac - cmd="$(cat "$proc/cmdline" 2>/dev/null | tr '\0' ' ')" - case "$cmd" in - *"/bin/openchamber serve"* | *"cli.js serve"*) ;; - *) continue ;; - esac - case "$cmd" in - # Argument boundary required: "--port 3000" must not match the - # 30001..30009 of an unrelated instance (cmdline words are - # space-separated here, trailing word included). - *"--port 3000 "*) leftovers="$leftovers $pid" ;; - *"--port=3000 "*) leftovers="$leftovers $pid" ;; - esac - done - if [ -n "$leftovers" ]; then - echo "openchamber-serve: reaping leftover server(s):$leftovers" >&2 - for pid in $leftovers; do - kill -TERM "$pid" 2>/dev/null || true - done - # OpenChamber drains HTTP for up to 10 s on SIGTERM. - for _ in $(seq 1 100); do - alive=0 - for pid in $leftovers; do - kill -0 "$pid" 2>/dev/null && alive=1 - done - [ "$alive" = 0 ] && break - sleep 0.1 - done - for pid in $leftovers; do - if kill -0 "$pid" 2>/dev/null; then - echo "openchamber-serve: pid $pid ignored SIGTERM; killing" >&2 - kill -KILL "$pid" 2>/dev/null || true - fi - done - # Verify synchronously, before taking the socket over: a leftover - # that could not be reaped fails this start loudly instead of - # silently sharing the listener with the new server. (An - # ExecStartPost assertion cannot do this: with Type=simple it - # races the guard's drain window.) - sleep 0.2 - for pid in $leftovers; do - if kill -0 "$pid" 2>/dev/null; then - echo "openchamber-serve: leftover server pid $pid could not be reaped; refusing to start a second server on port 3000" >&2 - exit 1 - fi - done - fi - pw="$HOME/.config/openchamber/ui-password" - if [ -r "$pw" ]; then - export OPENCHAMBER_UI_PASSWORD="$(< "$pw")" - fi - if [ -r "$HOME/.config/cloudflare/ai-inference-token" ]; then - export CLOUDFLARE_ACCOUNT_ID="$(< "$HOME/.config/cloudflare/account-id")" - export CLOUDFLARE_GATEWAY_ID="$(< "$HOME/.config/cloudflare/gateway-id")" - export CLOUDFLARE_API_TOKEN="$(< "$HOME/.config/cloudflare/ai-inference-token")" - fi - export OPENCODE_BINARY="${openchamberBinDir}/opencode" - export PATH="${openchamberBinDir}:$PATH" - exec ${inputs.openchamber.packages.${system}.openchamber}/bin/openchamber serve \ - --foreground \ - --port 3000 --host 127.0.0.1 - ''; - # The unit launches through the checkout wrapper (bin/openchamber-start.sh), - # which attaches OpenChamber to the standing OpenCode server - # (openchamber#766) and execs the serve script above, passed as its - # argument. The wrapper reads the server password from - # ~/.local/state/opencode/service-prod.json at start time and exports - # OPENCODE_HOST / OPENCODE_SKIP_START / OPENCODE_PASSWORD, so the - # password never enters the store or a unit file. This is the durable - # form of the hand-applied openchamber.service.d/external-opencode.conf - # drop-in; same fleet pattern as commandcode-proxy (the checkout path - # also avoids the stale-store ExecStart failure of #883). - openchamberUnitStart = pkgs.writeShellScript "openchamber-start-unit" '' - exec /run/current-system/sw/bin/bash "$HOME/code/bin/openchamber-start.sh" "${openchamberStart}" - ''; # A unit is replaced at switch time only when its start command or binaries change. deployKey = name: parts: "${name}:${builtins.concatStringsSep " " (map toString parts)}"; - # OpenChamber runs the OpenCode behind this link. A switch re-points it and - # reloads OpenChamber, so a new OpenCode takes over without a restart. - openchamberBinDir = "$HOME/.local/state/openchamber/bin"; in { wayland.windowManager.hyprland = { @@ -973,27 +877,78 @@ in Install.WantedBy = [ "default.target" ]; }; - # mcpx standing daemon: pool management and Code Mode runner. - # Runs independently on boot; survives openchamber/opencode restarts. - # Supports seamless hot reload via `mcpx reload` on SIGHUP or config changes. + # ── Service cascade (2026-11-03) ───────────────────────────────── + # The three standing services are defined by the fleet's layered + # modules now, not by hand-rolled units in this file: + # + # services.openchamber developing-today/openchamber, nix/modules + # services.opencode developing-today/opencode fork, nix/modules + # services.mcpx developing-today/code, pkgs/mcpx/modules + # + # Each layer's enable cascades to the one below with mkDefault, so + # the single switch here turns the whole stack on. OpenChamber + # attaches to the standing OpenCode server (openchamber#766, the + # one-process rule): the module's start wrapper reads the server's + # registration file, exports OPENCODE_PASSWORD / OPENCODE_HOST / + # OPENCODE_SKIP_START, reaps leftover servers on the port, and + # refuses to start unattached. What remains in this file is only + # this deployment's consumer configuration for the three modules, + # plus the mcpx handover machinery the modules do not carry. + # The cascade modules. NOTE: this file is merged into each user + # with lib.merge (a recursiveUpdate fold — see home/user and + # home/root), which keeps only one `imports` list; home/user + # re-declares the effective union there. This line is what applies + # for single-file merges (home/root). + imports = [ inputs.openchamber.homeManagerModules.openchamber ]; + + services.openchamber = { + enable = true; + # uiPasswordFile (the browser-UI password the old serve script + # read from ~/.config/openchamber/ui-password) is a per-user + # absolute path, so it is set in home/user, not in this shared + # file. (The CLOUDFLARE_* exports the old script also made are + # not lost with it: those values live in the systemd user + # manager's environment, via the hand-maintained + # ~/.config/environment.d/50-cloudflare.conf, and every user unit + # inherits them — the mcpx daemon receives them the same way.) + }; + + services.mcpx = { + # enable comes from the cascade (mkDefault at each layer). + # + # This repo's own mcpx build — the package the hand-rolled unit + # ran (pkgs/mcpx) — rather than the fork's re-export default. + package = mcpx; + # The daemon's environment, unchanged from the hand-rolled unit + # (mcpxEnvironment above). + environment = mcpxEnvironment; + # The daemon's configuration: mcpxSettings (mcpx-settings.nix, + # the former ~/code/.mcpx.json). The module renders it to the + # store, starts the daemon with --config pointing there, links + # ~/.config/mcpx/config.json to the rendered file, and points + # MCPX_CONFIG at it for other clients. + settings = mcpxSettings; + }; + + # Consumer refinements on the module's mcpx unit: the parts of the + # hand-rolled unit the module does not express. (Description, + # ExecStart, Restart = always and the 20 s stop window are the + # module's own.) systemd.user.services.mcpx = { Unit = { - Description = "mcpx standing MCP gateway daemon"; After = [ "network-online.target" ]; Wants = [ "network-online.target" ]; - # A switch must not restart the daemon: that would end every child. - # mcpxDeploy below hands a changed daemon over instead. + # A switch must not restart the daemon: that would end every + # pooled MCP child. mcpxDeploy below hands a changed daemon + # over instead. "X-RestartIfChanged" = false; }; Service = { Type = "notify"; NotifyAccess = "all"; - ExecStart = "${mcpxStart} ${mcpx}/bin/mcpx daemon"; ExecReload = "${mcpx}/bin/mcpx reload"; - Restart = "always"; RestartSec = 3; }; - Install.WantedBy = [ "default.target" ]; }; # A switch that changes mcpx, its start command or its environment hands the @@ -1017,123 +972,6 @@ in fi ''; - # Watch .mcpx.json to hot-reload the standing mcpx daemon seamlessly. - systemd.user.paths.mcpx-config = { - Unit.Description = "Watch .mcpx.json for live reload"; - Path = { - PathChanged = [ - "%h/code/.mcpx.json" - "%h/.config/mcpx/config.json" - ]; - Unit = "mcpx-reload.service"; - }; - Install.WantedBy = [ "default.target" ]; - }; - - systemd.user.services.mcpx-reload = { - Unit.Description = "Reload mcpx daemon configuration"; - Service = { - Type = "oneshot"; - ExecStart = "${mcpx}/bin/mcpx reload"; - }; - }; - - # systemd holds the listener across restarts, so connections made during a - # restart queue for the new process instead of being refused. - systemd.user.sockets.openchamber = { - Unit.Description = "OpenChamber listener"; - Socket.ListenStream = "127.0.0.1:3000"; - Install.WantedBy = [ "sockets.target" ]; - }; - - # The provider proxies are automatic services (Install.WantedBy - # default.target, #2104), so they are up independently of OpenChamber; - # OpenChamber reaches them by port, not by unit, and only mcpx is a - # real unit dependency here. The After ordering entries stay - # (ordering only, harmless). - systemd.user.services.openchamber = { - Unit = { - Description = "OpenChamber server"; - After = [ - "network-online.target" - "mcpx.service" - "clef-proxy.service" - "codex-proxy.service" - "antigravity-direct.service" - "design-code-proxy.service" - "openchamber.socket" - ]; - Wants = [ - "network-online.target" - "mcpx.service" - ]; - Requires = [ "openchamber.socket" ]; - }; - Service = { - ExecStart = "${openchamberUnitStart}"; - ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; - # Stopping OpenChamber leaves its managed OpenCode running; the next - # OpenChamber adopts it, so sessions survive a restart. The same - # KillMode lets an untracked server survive a stop with the socket - # attached -- the start script reaps leftovers (dezren39/nix#1117). - KillMode = "process"; - # A self-handoff successor names itself the main pid (MAINPID=) from a child process. - # With NotifyAccess=none systemd ignores it, so the unit stops when the old process exits. - NotifyAccess = "all"; - Restart = "on-failure"; - RestartSec = 5; - Environment = [ - "PATH=${ - lib.makeBinPath [ - mcpx - pkgs.git - pkgs.openssh - # The start script's single-instance guard scans /proc with - # coreutils (readlink, cat, tr, seq, sleep); without it the - # guard silently matches nothing. jq is for the checkout - # wrapper (bin/openchamber-start.sh), which reads the - # standing OpenCode server's state file. - pkgs.coreutils - pkgs.jq - ] - }" - ]; - }; - Install.WantedBy = [ "default.target" ]; - }; - - # A new OpenChamber start command restarts the unit. A new OpenCode only moves - # the link and reloads OpenChamber, which hands its OpenCode over in place. - home.activation.openchamberDeploy = lib.hm.dag.entryAfter [ "reloadSystemd" ] '' - state="''${XDG_STATE_HOME:-$HOME/.local/state}/openchamber/deployed" - key='${ - deployKey "openchamber" [ - openchamberStart - openchamberUnitStart - ] - }' - link="$HOME/.local/state/openchamber/bin/opencode" - target="${inputs.opencode.packages.${system}.opencode}/bin/opencode" - previous="$(readlink "$link" 2>/dev/null || true)" - active=0 - if ${pkgs.systemd}/bin/systemctl --user is-system-running --quiet 2>/dev/null; then - if ${pkgs.systemd}/bin/systemctl --user is-active --quiet openchamber.service 2>/dev/null; then - active=1 - fi - fi - run mkdir -p "$HOME/.local/state/openchamber/bin" - run ln -sfn "$target" "$link" - if [ "$(cat "$state" 2>/dev/null)" != "$key" ]; then - if [ "$active" = 1 ]; then - run ${pkgs.systemd}/bin/systemctl --user restart openchamber.service - fi - run mkdir -p "$(dirname "$state")" - run sh -c 'printf "%s\n" "$1" > "$2"' _ "$key" "$state" - elif [ "$active" = 1 ] && [ "$previous" != "$target" ]; then - run ${pkgs.systemd}/bin/systemctl --user reload openchamber.service - fi - ''; - # T3 Code's backend, run headless over the tailnet. # # The server package (latestCli.t3) ships a `t3` binary whose whole purpose diff --git a/home/common/mcpx-settings.nix b/home/common/mcpx-settings.nix new file mode 100644 index 0000000000..65b55ce64f --- /dev/null +++ b/home/common/mcpx-settings.nix @@ -0,0 +1,100 @@ +# The mcpx daemon's configuration (services.mcpx.settings in +# home/common/default.nix), as a pure data file. +# +# This is the former ~/code/.mcpx.json — the daemon's hand-maintained +# config, which ~/.config/mcpx/config.json used to link to — moved +# into the Nix configuration with the 2026-11-03 cascade migration. +# The mcpx module renders it to the store and starts the daemon with +# --config pointing there; ~/.config/mcpx/config.json is now a link +# to the rendered file. To change the daemon's servers, edit this +# file and switch — editing a JSON file in the checkout no longer +# reaches the daemon. +{ + "$schema" = "https://raw.githubusercontent.com/dezren39/mcpx/main/schema/mcpx.schema.json"; + "mcpServers" = { + "antigravity" = { + "args" = [ "-y" "@ask-llm/antigravity-mcp" ]; + "command" = "npx"; + }; + "antigravity-jules-orchestration" = { + "args" = [ "-y" "@iflow-mcp/scarmonit-antigravity-jules-orchestration" ]; + "command" = "npx"; + }; + "chrome-devtools" = { + "args" = [ "-y" "chrome-devtools-mcp@latest" "--executable-path=/run/current-system/sw/bin/chromium" "--headless" "--isolated" "--viewport=800x600" "--no-usage-statistics" "--no-performance-crux" "--no-category-emulation" ]; + "command" = "npx"; + "mcpx" = { + "scope" = "session"; + "sharing" = "exclusive"; + }; + }; + "cloudrun" = { + "args" = [ "-y" "@google-cloud/cloud-run-mcp" ]; + "command" = "npx"; + }; + "codebase-memory" = { + "args" = [ "-y" "codebase-memory-mcp" ]; + "command" = "npx"; + }; + "codedb" = { + "args" = [ "/home/user/git/code/bin/codedb-bridge.mjs" ]; + "command" = "node"; + "env" = { + "CODEDB_DAEMON_URL" = "http://127.0.0.1:7719"; + "CODEDB_NO_TELEMETRY" = "1"; + }; + }; + "codex-connectors" = { + "args" = [ "-y" "@wileai/codex-connectors-mcp@0.1.1" ]; + "command" = "npx"; + "env" = { + "CODEX_CONNECTORS_ALLOW" = "Airtable, ChatGPT Space, Codex Document Control, Context.dev, Context7, DigitalOcean, Dropbox, Engram, Exa, Firecrawl, GitHub, Gmail, Google Calendar, Google Drive, HAPI MCP Registry, Hotline, Lovable, Neon, OpenAI Platform, Parallel Search, Pets, Plugin Management, Railway, Remote Desktop Commander, Replit, Safety Settings, Search Service, Sites, Slack, Sprites, Stack Overflow For Agents, Supabase, tldraw, Todoist: To Do List & Calendar, Vercel, Walmart, Wolfram"; + "CODEX_CONNECTORS_MODE" = "compact"; + }; + }; + "context7" = { + "args" = [ "-y" "mcp-remote" "https://mcp.context7.com/mcp" ]; + "command" = "npx"; + }; + "deepwiki" = { + "args" = [ "-y" "mcp-remote" "https://mcp.deepwiki.com/mcp" ]; + "command" = "npx"; + }; + "desktop-commander" = { + "args" = [ "-y" "@wonderwhy-er/desktop-commander" ]; + "command" = "npx"; + }; + "fff" = { + "args" = [ ]; + "command" = "/home/user/.local/bin/fff-mcp"; + }; + "fff-nix" = { + "args" = [ "/home/user/code" ]; + "command" = "/home/user/.local/bin/fff-mcp"; + }; + "fff-worktree" = { + "args" = [ "/home/user/.local/share/opencode/worktree" ]; + "command" = "/home/user/.local/bin/fff-mcp"; + }; + "gopls-mcp-server" = { + "args" = [ "run" "golang.org/x/tools/gopls@latest" "mcp" ]; + "command" = "go"; + }; + "jules" = { + "args" = [ "-y" "@google/jules-mcp" ]; + "command" = "npx"; + }; + "mcp-server-neon" = { + "args" = [ "-y" "mcp-remote" "https://mcp.neon.tech/sse" ]; + "command" = "npx"; + }; + "sequential-thinking" = { + "args" = [ "-y" "@modelcontextprotocol/server-sequential-thinking" ]; + "command" = "npx"; + }; + }; + "repair" = { + "model" = "claude-code/claude-haiku-5-5"; + "provider" = "opencode"; + }; +} diff --git a/home/user/default.nix b/home/user/default.nix index f14794dfd8..8b6d7920e4 100755 --- a/home/user/default.nix +++ b/home/user/default.nix @@ -27,5 +27,25 @@ system ; }) + # The merged files' flake-module imports, gathered. lib.merge is + # a recursiveUpdate fold, which keeps only ONE `imports` list — + # the last one — so the per-file `imports` lines (home/common's + # cascade modules, home/openclaw's module) do not take effect for + # this user on their own; this element is the effective union. + # (home/root merges home/common alone, where its own line does + # apply.) Keep this list in step with the files above. + { + imports = [ + inputs.nix-openclaw.homeManagerModules.openclaw + inputs.openchamber.homeManagerModules.openchamber + ]; + + # The OpenChamber browser-UI password file for THIS user (the + # cascade's per-user setting; home/common stays user-agnostic). + # The module's start wrapper exports it as + # OPENCHAMBER_UI_PASSWORD when readable, as the old serve + # script did. + services.openchamber.uiPasswordFile = "/home/user/.config/openchamber/ui-password"; + } ]; }