Skip to content

Commit f452da3

Browse files
authored
Merge pull request DeusData#1089 from mipmip/feat/nix-ui-package
feat(nix): add UI-embedded flake package, refresh lock + docs
2 parents 4ec0f5f + 2a02d12 commit f452da3

4 files changed

Lines changed: 91 additions & 5 deletions

File tree

‎.gitignore‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,7 @@ soak-results-query-leak/
8686
# Scorecard as a binary artifact in source). Source only, never the build.
8787
/pkg/go/codebase-memory-mcp
8888
/pkg/go/codebase-memory-mcp.exe
89+
90+
# Nix build symlinks (nix build → ./result, ./result-1, …)
91+
/result
92+
/result-*

‎README.md‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,38 @@ paru -S codebase-memory-mcp-bin
355355

356356
The `codebase-memory-mcp-bin` package is available at: https://aur.archlinux.org/packages/codebase-memory-mcp-bin
357357

358+
### Nix (flake)
359+
360+
The flake exposes two server packages plus the standalone frontend:
361+
362+
| Package | Contents |
363+
|---------|----------|
364+
| `default` (`codebase-memory-mcp`) | Standard server, no UI |
365+
| `codebase-memory-mcp-ui` | Server with the graph UI embedded (`--ui=true` works) |
366+
| `graph-ui` | Just the built frontend assets (`dist/`) |
367+
368+
Run directly without installing:
369+
370+
```bash
371+
# Standard server
372+
nix run github:DeusData/codebase-memory-mcp
373+
374+
# Server with the embedded graph UI
375+
nix run github:DeusData/codebase-memory-mcp#codebase-memory-mcp-ui -- --ui=true --port=9749
376+
# then open http://127.0.0.1:9749
377+
```
378+
379+
Or build a binary into `./result/bin/codebase-memory-mcp`:
380+
381+
```bash
382+
nix build github:DeusData/codebase-memory-mcp # standard
383+
nix build github:DeusData/codebase-memory-mcp#codebase-memory-mcp-ui # with UI
384+
```
385+
386+
Working in a clone? Use `.` in place of the flake URL, e.g. `nix run .#codebase-memory-mcp-ui -- --ui=true`, or drop into a shell that puts the binary on `PATH` with `nix shell .#codebase-memory-mcp-ui`.
387+
388+
> **Note:** launched by hand (not from an MCP client) the server exits as soon as `stdin` closes — that's normal MCP behaviour. Keep `stdin` open while testing the UI, e.g. `sleep infinity | codebase-memory-mcp --ui=true --port=9749`. The `codebase-memory-mcp-ui` package embeds the UI at build time; `nix run`'ing the standard `default` package with `--ui=true` will refuse to start the HTTP server.
389+
358390
### Install via Claude Code
359391

360392
```

‎flake.lock‎

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎flake.nix‎

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@
6060
};
6161
in
6262
{
63-
packages = forAllSystems (pkgs: {
63+
packages = forAllSystems (pkgs: rec {
6464
default = pkgs.stdenv.mkDerivation {
6565
pname = "codebase-memory-mcp";
66-
version = "0.6.0";
66+
version = "0.10.8";
6767

6868
src = ./.;
6969

@@ -90,6 +90,56 @@
9090
platforms = systems;
9191
};
9292
};
93+
94+
# The graph-ui React frontend, built to static assets (graph-ui/dist).
95+
# buildNpmPackage fetches npm deps offline via the pinned package-lock.json;
96+
# bump npmDepsHash whenever that lockfile changes:
97+
# nix run nixpkgs#prefetch-npm-deps -- graph-ui/package-lock.json
98+
graph-ui = pkgs.buildNpmPackage {
99+
pname = "codebase-memory-graph-ui";
100+
version = "0.1.0";
101+
102+
src = ./graph-ui;
103+
104+
npmDepsHash = "sha256-P1JVo+GFr+Gsq88dnn9OsedZqrTaj3DDGbej+nHbp4U=";
105+
106+
# `npm run build` runs `tsc -b && vite build`, emitting to dist/.
107+
installPhase = ''
108+
runHook preInstall
109+
cp -r dist $out
110+
runHook postInstall
111+
'';
112+
};
113+
114+
# Same server binary as `default`, but with the graph-ui assets embedded
115+
# so `--ui=true` starts the HTTP server. The frontend is built separately
116+
# by the graph-ui package above; here we drop its dist/ into place and run
117+
# the embed + link path (cbm-with-ui) — no network access needed.
118+
codebase-memory-mcp-ui = default.overrideAttrs (old: {
119+
pname = "codebase-memory-mcp-ui";
120+
121+
buildPhase = ''
122+
# cbm-with-ui depends on `embed`, which depends on `frontend`, which
123+
# runs `npm ci && npm run build` — needs network access, unavailable
124+
# in the sandbox. Supply the pre-built assets, run the embed script
125+
# directly, then link with `cbm-with-ui` while telling make its
126+
# `frontend`/`embed` prerequisites are already up to date (-o) so it
127+
# won't re-run the npm build.
128+
mkdir -p graph-ui/dist
129+
cp -r ${graph-ui}/. graph-ui/dist/
130+
chmod -R u+w graph-ui/dist
131+
132+
bash scripts/embed-frontend.sh graph-ui/dist build/c/embedded
133+
134+
make -j$NIX_BUILD_CORES -f Makefile.cbm \
135+
-o frontend -o embed \
136+
cbm-with-ui
137+
'';
138+
139+
meta = old.meta // {
140+
description = "codebase-memory-mcp with the embedded graph UI (--ui)";
141+
};
142+
});
93143
});
94144

95145
devShells = forAllSystems (pkgs: {

0 commit comments

Comments
 (0)