Skip to content

Commit 81235a1

Browse files
author
Joseph Voss
committed
Add Nix flake definition for reproducible builds
Adds `flake.nix` to define how this package should be built on systems running [nix][nix-link]. Also commit the `flake.lock` file to pin the specific dependencies at build time. By default support aarch64 and x86_64 for macos and linux. Run the Make command directly because `cc` on Nix systems is a wrapper file and not a binary directly, so the `file` check in `scripts/build.sh` fails to identify the host architecture correctly. Include lib2git as an optional dev shell dependency since it's detected by `pkg-config` in the build script to link to `lib2git` if it exists at build time. [nix-link]: https://nixos.org/
1 parent bebc6d8 commit 81235a1

2 files changed

Lines changed: 81 additions & 0 deletions

File tree

flake.lock

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

flake.nix

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
description = "codebase-memory-mcp — C11 MCP server for codebase indexing";
3+
4+
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
5+
6+
outputs = { self, nixpkgs }:
7+
let
8+
systems = [ "aarch64-darwin" "x86_64-darwin" "aarch64-linux" "x86_64-linux" ];
9+
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
10+
in
11+
{
12+
packages = forAllSystems (pkgs: {
13+
default = pkgs.stdenv.mkDerivation {
14+
pname = "codebase-memory-mcp";
15+
version = "0.6.0";
16+
17+
src = ./.;
18+
19+
nativeBuildInputs = [ pkgs.gnumake ];
20+
buildInputs = [ pkgs.zlib ];
21+
22+
# scripts/build.sh verifies the compiler via `file`, which fails on Nix
23+
# because CC is a bash wrapper script rather than a binary. Call make
24+
# directly to bypass that check; the Nix stdenv already guarantees the
25+
# correct compiler and target architecture.
26+
buildPhase = ''
27+
make -j$NIX_BUILD_CORES -f Makefile.cbm cbm
28+
'';
29+
30+
installPhase = ''
31+
install -Dm755 build/c/codebase-memory-mcp $out/bin/codebase-memory-mcp
32+
'';
33+
34+
meta = {
35+
description = "MCP server that builds and queries a semantic graph of your codebase";
36+
homepage = "https://github.com/DeusData/codebase-memory-mcp";
37+
license = nixpkgs.lib.licenses.mit;
38+
mainProgram = "codebase-memory-mcp";
39+
platforms = systems;
40+
};
41+
};
42+
});
43+
44+
devShells = forAllSystems (pkgs: {
45+
default = pkgs.mkShell {
46+
inputsFrom = [ self.packages.${pkgs.system}.default ];
47+
# libgit2 is an optional dependency auto-detected via pkg-config at
48+
# build time. When present it accelerates git history parsing;
49+
# otherwise the build falls back to shelling out to `git log`.
50+
packages = [ pkgs.pkg-config pkgs.libgit2 ];
51+
};
52+
});
53+
};
54+
}

0 commit comments

Comments
 (0)