Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@ test-languages/

nul
release/

# Nix
result
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

85 changes: 85 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
description = "CodeGraph – semantic code intelligence for AI agents";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};

nodejs = pkgs.nodejs_24;

codegraph = pkgs.buildNpmPackage {
pname = "codegraph";
version =
(builtins.fromJSON (builtins.readFile ./package.json)).version;

src = ./.;

npmDeps = pkgs.fetchNpmDeps {
src = ./.;
hash = "sha256-GJfqzykgrgD/KCtf8LupRw31S2cCmwGCF/0PMpzaCrk=";
};

inherit nodejs;

npmBuildScript = "build";

# The build copies .wasm + schema.sql into dist/ via the
# `copy-assets` npm script (called from `build`). Nothing
# extra to do here.

installPhase = ''
runHook preInstall

# Application code
mkdir -p $out/lib/codegraph
cp -r dist $out/lib/codegraph/dist
cp package.json $out/lib/codegraph/

# Production node_modules (already populated by buildNpmPackage)
cp -r node_modules $out/lib/codegraph/node_modules

# Launcher wrapper: injects --liftoff-only so tree-sitter's
# large WASM grammars stay on V8's Liftoff baseline compiler
# and never hit the turboshaft Zone OOM (issues #293/#298).
mkdir -p $out/bin
cat > $out/bin/codegraph <<'EOF'
#!/bin/sh
exec @node@ --liftoff-only @out@/lib/codegraph/dist/bin/codegraph.js "$@"
EOF
substituteInPlace $out/bin/codegraph \
--replace-fail '@node@' '${nodejs}/bin/node' \
--replace-fail '@out@' "$out"
chmod +x $out/bin/codegraph

runHook postInstall
'';

# No native addons to build — pure JS + WASM.
dontNpmBuild = false;

meta = with pkgs.lib; {
description =
"Semantic code intelligence for AI agents — local-first knowledge graph over tree-sitter";
homepage = "https://github.com/colbymchenry/codegraph";
license = licenses.mit;
mainProgram = "codegraph";
platforms = platforms.unix;
};
};
in {
packages = {
default = codegraph;
inherit codegraph;
};

devShells.default = pkgs.mkShell {
buildInputs = [ nodejs ];
};
});
}