Skip to content
Closed
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
25 changes: 25 additions & 0 deletions pkgs/by-name/tr/tree-sitter/grammars/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,31 @@ Attempt to build the new grammar: `nix-build -A tree-sitter-grammars.tree-sitter
This will fail due to the invalid hash.
Review the downloaded source, then update the source definition with the printed source `hash`.

## Extending Grammars

Overlays may extend the grammar set without modifying nixpkgs by overriding `tree-sitter` with `extraGrammars`.
Extra grammars use the expanded `pkgs.tree-sitter.grammars` form: each key is the final `tree-sitter-*` attribute name, and each value provides `language`, `version`, and `src`.
When added through an overlay, extra grammars are also available through `pkgs.tree-sitter.builtGrammars`, `pkgs.tree-sitter-grammars`, and `pkgs.tree-sitter.withPlugins`.

```nix
final: prev: {
tree-sitter = prev.tree-sitter.override {
extraGrammars = {
tree-sitter-foolang = {
language = "foolang";
version = "0.42.0";
src = final.fetchFromGitHub {
owner = "example";
repo = "tree-sitter-foolang";
tag = "v0.42.0";
hash = "";
};
};
};
};
}
```

## Pinning Grammar Sources

To pin to a specific ref, append this to the source `url` to override the default version tag.
Expand Down
27 changes: 15 additions & 12 deletions pkgs/by-name/tr/tree-sitter/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
enableStatic ? stdenv.hostPlatform.isStatic,
wasmSupport ? false,
webUISupport ? false,
extraGrammars ? { },
}:

let
Expand Down Expand Up @@ -52,18 +53,20 @@ let

Use pkgs.tree-sitter.grammars.<name> to access.
*/
grammars = import ./grammars {
inherit
lib
nix-update-script
fetchFromGitHub
fetchFromGitLab
fetchFromSourcehut
fetchFromCodeberg
fetchpatch
stdenv
;
};
grammars =
import ./grammars {
inherit
lib
nix-update-script
fetchFromGitHub
fetchFromGitLab
fetchFromSourcehut
fetchFromCodeberg
fetchpatch
stdenv
;
}
// extraGrammars;

/**
Attrset of compiled grammars.
Expand Down
Loading