generated from nix-community/nur-packages-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tree-sitter-languages.nix
70 lines (61 loc) · 1.67 KB
/
tree-sitter-languages.nix
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
{ lib
, python3
, fetchFromGitHub
, tree-sitter-grammars
}:
python3.pkgs.buildPythonPackage rec {
pname = "tree-sitter-languages";
version = "1.10.2";
pyproject = true;
src = fetchFromGitHub {
owner = "grantjenks";
repo = "py-tree-sitter-languages";
rev = "v${version}";
hash = "sha256-AuPK15xtLiQx6N2OATVJFecsL8k3pOagrWu1GascbwM=";
};
patches = [
# this has 2 benefits:
# 1. this package builds 1000x faster
# 2. no more symbol conflicts between parsers
# https://github.com/grantjenks/py-tree-sitter-languages/issues/55
./use-prebuilt-grammars.patch
];
buildInputs = [
python3.pkgs.cython
];
nativeBuildInputs = [
python3.pkgs.setuptools
python3.pkgs.wheel
];
propagatedBuildInputs = [
python3.pkgs.tree-sitter
];
postBuild = ''
languages=$out/${python3.sitePackages}/tree_sitter_languages/languages
echo creating $languages
mkdir -p $languages
${
builtins.concatStringsSep "" (
builtins.attrValues (
builtins.mapAttrs
(_n: p:
# 12 == builtins.stringLength "tree-sitter-"
let n = builtins.substring 12 999 _n; in
''
echo adding language ${n}
ln -s ${p.outPath}/parser $languages/${n}
''
)
(lib.filterAttrs (k: v: v ? outPath) tree-sitter-grammars)
)
)
}
'';
pythonImportsCheck = [ "tree_sitter_languages" ];
meta = with lib; {
description = "Python module with all tree-sitter languages";
homepage = "https://github.com/grantjenks/py-tree-sitter-languages";
license = licenses.asl20;
maintainers = with maintainers; [ ];
};
}