forked from colbymchenry/codegraph
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflake.nix
More file actions
89 lines (70 loc) · 2.65 KB
/
flake.nix
File metadata and controls
89 lines (70 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
{
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-zUdbsqQQKTH+Y3jtFGpQh3sIUTP+cnAv1NbJ0NNF98Q=";
};
inherit nodejs;
npmBuildScript = "build";
npmInstallFlags = [ "--ignore-scripts" ];
dontNpmRebuild = true;
# 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 ];
};
});
}