tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
vimPlugins.nvim-treesitter: switch to nurl in update script
figsoda
3 years ago
b12686d5
67b0f840
+7
-48
3 changed files
expand all
collapse all
unified
split
pkgs
applications
editors
vim
plugins
nvim-treesitter
generated.nix
update-shell.nix
update.py
+1
-1
pkgs/applications/editors/vim/plugins/nvim-treesitter/generated.nix
···
1
1
# generated by pkgs/applications/editors/vim/plugins/nvim-treesitter/update.py
2
2
3
3
-
{ buildGrammar, fetchFromGitHub, fetchFromGitLab, fetchgit }:
3
3
+
{ buildGrammar, fetchFromGitHub, fetchFromGitLab, fetchFromSourcehut, fetchgit }:
4
4
5
5
{
6
6
ada = buildGrammar {
+1
-1
pkgs/applications/editors/vim/plugins/nvim-treesitter/update-shell.nix
···
11
11
in
12
12
13
13
mkShell {
14
14
-
packages = [ neovim nix-prefetch python3 ];
14
14
+
packages = [ neovim nurl python3 ];
15
15
16
16
NVIM_TREESITTER = nvim-treesitter;
17
17
}
+5
-46
pkgs/applications/editors/vim/plugins/nvim-treesitter/update.py
···
2
2
#!nix-shell update-shell.nix -i python
3
3
4
4
import json
5
5
-
import re
6
5
import subprocess
6
6
+
from concurrent.futures import ThreadPoolExecutor
7
7
from os import environ
8
8
from os.path import dirname, join
9
9
···
21
21
]
22
22
)
23
23
)
24
24
-
25
25
-
regex = re.compile("^https?://(github.com|gitlab.com)/(.+?)/(.+?)(.git)?$")
26
24
27
25
28
26
def generate_grammar(item):
···
40
38
version = "{rev[:7]}";
41
39
source = """
42
40
43
43
-
m = regex.fullmatch(url)
44
44
-
cmd = ["nix-prefetch", "--rev", rev]
45
45
-
46
46
-
match m and m.group(1, 2, 3):
47
47
-
case "github.com", owner, repo:
48
48
-
cmd += [
49
49
-
"fetchFromGitHub",
50
50
-
"--owner",
51
51
-
owner,
52
52
-
"--repo",
53
53
-
repo,
54
54
-
]
55
55
-
56
56
-
generated += f"""fetchFromGitHub {{
57
57
-
owner = "{owner}";
58
58
-
repo = "{repo}";"""
59
59
-
60
60
-
case "gitlab.com", owner, repo:
61
61
-
cmd += [
62
62
-
"fetchFromGitLab",
63
63
-
"--owner",
64
64
-
owner,
65
65
-
"--repo",
66
66
-
repo,
67
67
-
]
68
68
-
69
69
-
generated += f"""fetchFromGitLab {{
70
70
-
owner = "{owner}";
71
71
-
repo = "{repo}";"""
72
72
-
73
73
-
case _:
74
74
-
cmd += ["fetchgit", "--url", url]
75
75
-
generated += f"""fetchgit {{
76
76
-
url = "{url}";"""
77
77
-
78
78
-
hash = subprocess.check_output(cmd, text=True).strip()
79
79
-
80
80
-
generated += f"""
81
81
-
rev = "{rev}";
82
82
-
hash = "{hash}";
83
83
-
}};"""
41
41
+
generated += subprocess.check_output(["nurl", url, rev, "--indent=4"], text=True)
42
42
+
generated += ";"
84
43
85
44
location = info.get("location")
86
45
if location:
···
101
60
102
61
generated_file = """# generated by pkgs/applications/editors/vim/plugins/nvim-treesitter/update.py
103
62
104
104
-
{ buildGrammar, fetchFromGitHub, fetchFromGitLab, fetchgit }:
63
63
+
{ buildGrammar, fetchFromGitHub, fetchFromGitLab, fetchFromSourcehut, fetchgit }:
105
64
106
65
{
107
66
"""
108
67
109
109
-
for generated in map(generate_grammar, lockfile.items()):
68
68
+
for generated in ThreadPoolExecutor().map(generate_grammar, lockfile.items()):
110
69
generated_file += generated
111
70
112
71
generated_file += "}\n"