File tree Expand file tree Collapse file tree 2 files changed +11
-15
lines changed Expand file tree Collapse file tree 2 files changed +11
-15
lines changed Original file line number Diff line number Diff line change 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 {
Original file line number Diff line number Diff line change @@ -21,13 +21,15 @@ docker buildx build \
2121docker 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
You can’t perform that action at this time.
0 commit comments