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 26
26
in rec {
27
27
packages = rec {
28
28
29
+ # https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/go/module.nix
29
30
goBinary = pkgs . buildGoModule {
30
31
pname = "tree-sitter-query" ;
31
32
version = "0.1.0" ;
32
33
src = ./. ; # Assuming your Go code is in the same directory as the flake.nix
33
34
34
- buildInputs = [ pkgs . tree-sitter ] ;
35
-
36
35
CGO_ENABLED = "1" ;
37
36
38
- CGO_CFLAGS = "-I${ pkgs . tree-sitter } /include" ;
39
-
40
- # If you have vendored dependencies, use this:
41
- # vendorSha256 = null;
42
-
43
37
# If you're not using vendored dependencies, compute the hash of your go.mod and go.sum
44
38
# You can get this hash by first setting it to lib.fakeSha256,
45
39
# then running the build and replacing it with the correct hash
46
40
vendorHash = "sha256-/X9cuzpVzVOqcON3c2GtUwCXi6gfFzjjQ8r+D0Yhgu8=" ;
41
+
42
+ postInstall = ''
43
+ mv $out/bin/ts $out/bin/entrypoint
44
+ '' ;
47
45
48
46
# Specify the package to build if it's not in the root of your project
49
47
subPackages = [ "cmd/ts" ] ;
50
48
} ;
51
49
52
- default = pkgs . writeShellScriptBin "entrypoint" ''
53
- export PATH=${ pkgs . lib . makeBinPath [ goBinary ] }
54
- ts "$@"
55
- '' ;
56
-
50
+ default = goBinary ;
57
51
} ;
58
52
59
53
devShells . default = pkgs . devshell . mkShell {
Original file line number Diff line number Diff line change @@ -21,13 +21,15 @@ docker buildx build \
21
21
docker pull vonwig/tree-sitter:latest
22
22
```
23
23
24
+ ## Run
25
+
24
26
``` 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
27
29
```
28
30
29
31
``` sh
30
- ./result/bin/ts -lang markdown < test/resources/hello.md
32
+ ./result/bin/entrypoint -lang markdown < test/resources/hello.md
31
33
```
32
34
33
35
``` sh
You can’t perform that action at this time.
0 commit comments