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
|
{
lib,
buildPythonPackage,
fetchPypi,
pytestCheckHook,
nix-update-script,
# build-system
cython,
setuptools,
typing-extensions,
# dependencies
tree-sitter,
tree-sitter-c-sharp,
tree-sitter-embedded-template,
tree-sitter-yaml,
}:
buildPythonPackage rec {
pname = "tree-sitter-language-pack";
version = "0.13.0";
pyproject = true;
# Using the GitHub sources necessitates fetching the treesitter grammar parsers by using a vendored script.
# The pypi archive has the benefit of already vendoring those dependencies which makes packaging easier on our side
# See: https://github.com/Goldziher/tree-sitter-language-pack/blob/main/scripts/clone_vendors.py
src = fetchPypi {
pname = "tree_sitter_language_pack";
inherit version;
hash = "sha256-AyA0xeJ7H24AcwuefC28ggO0cA0MaB/QGdbe/PYRg+w=";
};
# Upstream bumped dependencies aggressively, but we can still use older
# versions since the newer ones aren’t packaged in nixpkgs. We can't use
# pythonRelaxDepsHook here because it runs in postBuild, while the dependency
# check occurs during the build phase.
postPatch = ''
substituteInPlace pyproject.toml \
--replace-fail "typing-extensions>=4.15.0" "typing-extensions>=4.14.1"
'';
nativeCheckInputs = [
pytestCheckHook
];
build-system = [
cython
setuptools
typing-extensions
];
dependencies = [
tree-sitter
tree-sitter-c-sharp
tree-sitter-embedded-template
tree-sitter-yaml
];
pythonRelaxDeps = [
"tree-sitter"
"tree-sitter-embedded-template"
"tree-sitter-yaml"
];
pythonImportsCheck = [
"tree_sitter_language_pack"
"tree_sitter_language_pack.bindings"
];
# make sure import the built version, not the source one
preCheck = ''
rm -r tree_sitter_language_pack
'';
passthru.updateScript = nix-update-script { };
meta = {
description = "Comprehensive collection of tree-sitter languages";
homepage = "https://github.com/Goldziher/tree-sitter-language-pack";
changelog = "https://github.com/Goldziher/tree-sitter-language-pack/releases/tag/v${version}";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ yzx9 ];
};
}
|