Skip to content

Commit de7226e

Browse files
AI generated image included bash
* instead, call tree-sitter binary directly
1 parent b920a03 commit de7226e

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

functions/tree-sitter/flake.nix

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,34 +26,28 @@
2626
in rec {
2727
packages = rec {
2828

29+
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/go/module.nix
2930
goBinary = pkgs.buildGoModule {
3031
pname = "tree-sitter-query";
3132
version = "0.1.0";
3233
src = ./.; # Assuming your Go code is in the same directory as the flake.nix
3334

34-
buildInputs = [pkgs.tree-sitter];
35-
3635
CGO_ENABLED = "1";
3736

38-
CGO_CFLAGS = "-I${pkgs.tree-sitter}/include";
39-
40-
# If you have vendored dependencies, use this:
41-
# vendorSha256 = null;
42-
4337
# If you're not using vendored dependencies, compute the hash of your go.mod and go.sum
4438
# You can get this hash by first setting it to lib.fakeSha256,
4539
# then running the build and replacing it with the correct hash
4640
vendorHash = "sha256-/X9cuzpVzVOqcON3c2GtUwCXi6gfFzjjQ8r+D0Yhgu8=";
41+
42+
postInstall = ''
43+
mv $out/bin/ts $out/bin/entrypoint
44+
'';
4745

4846
# Specify the package to build if it's not in the root of your project
4947
subPackages = [ "cmd/ts" ];
5048
};
5149

52-
default = pkgs.writeShellScriptBin "entrypoint" ''
53-
export PATH=${pkgs.lib.makeBinPath [goBinary]}
54-
ts "$@"
55-
'';
56-
50+
default = goBinary;
5751
};
5852

5953
devShells.default = pkgs.devshell.mkShell {

functions/tree-sitter/runbook.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ docker buildx build \
2121
docker pull vonwig/tree-sitter:latest
2222
```
2323

24+
## Run
25+
2426
```sh
25-
./result/bin/ts -lang python -query "(module (function_definition) @top-level)" < test/resources/hello.py
26-
./result/bin/ts -lang markdown -query "(document (section (atx_heading (atx_h1_marker))) @h1)" < test/resources/hello.md
27+
./result/bin/entrypoint -lang python -query "(module (function_definition) @top-level)" < test/resources/hello.py
28+
./result/bin/entrypoint -lang markdown -query "(document (section (atx_heading (atx_h1_marker))) @h1)" < test/resources/hello.md
2729
```
2830

2931
```sh
30-
./result/bin/ts -lang markdown < test/resources/hello.md
32+
./result/bin/entrypoint -lang markdown < test/resources/hello.md
3133
```
3234

3335
```sh

0 commit comments

Comments
 (0)