Merge pull request #208306 from figsoda/nurl
vimPlugins.nvim-treesitter: switch to nurl in update script
This commit is contained in:
commit
6f94877eb3
|
@ -1,6 +1,6 @@
|
|||
# generated by pkgs/applications/editors/vim/plugins/nvim-treesitter/update.py
|
||||
|
||||
{ buildGrammar, fetchFromGitHub, fetchFromGitLab, fetchgit }:
|
||||
{ buildGrammar, fetchFromGitHub, fetchFromGitLab, fetchFromSourcehut, fetchgit }:
|
||||
|
||||
{
|
||||
ada = buildGrammar {
|
||||
|
|
|
@ -11,7 +11,7 @@ let
|
|||
in
|
||||
|
||||
mkShell {
|
||||
packages = [ neovim nix-prefetch python3 ];
|
||||
packages = [ neovim nurl python3 ];
|
||||
|
||||
NVIM_TREESITTER = nvim-treesitter;
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#!nix-shell update-shell.nix -i python
|
||||
|
||||
import json
|
||||
import re
|
||||
import subprocess
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from os import environ
|
||||
from os.path import dirname, join
|
||||
|
||||
|
@ -22,8 +22,6 @@ configs = json.loads(
|
|||
)
|
||||
)
|
||||
|
||||
regex = re.compile("^https?://(github.com|gitlab.com)/(.+?)/(.+?)(.git)?$")
|
||||
|
||||
|
||||
def generate_grammar(item):
|
||||
lang, lock = item
|
||||
|
@ -40,47 +38,8 @@ def generate_grammar(item):
|
|||
version = "{rev[:7]}";
|
||||
source = """
|
||||
|
||||
m = regex.fullmatch(url)
|
||||
cmd = ["nix-prefetch", "--rev", rev]
|
||||
|
||||
match m and m.group(1, 2, 3):
|
||||
case "github.com", owner, repo:
|
||||
cmd += [
|
||||
"fetchFromGitHub",
|
||||
"--owner",
|
||||
owner,
|
||||
"--repo",
|
||||
repo,
|
||||
]
|
||||
|
||||
generated += f"""fetchFromGitHub {{
|
||||
owner = "{owner}";
|
||||
repo = "{repo}";"""
|
||||
|
||||
case "gitlab.com", owner, repo:
|
||||
cmd += [
|
||||
"fetchFromGitLab",
|
||||
"--owner",
|
||||
owner,
|
||||
"--repo",
|
||||
repo,
|
||||
]
|
||||
|
||||
generated += f"""fetchFromGitLab {{
|
||||
owner = "{owner}";
|
||||
repo = "{repo}";"""
|
||||
|
||||
case _:
|
||||
cmd += ["fetchgit", "--url", url]
|
||||
generated += f"""fetchgit {{
|
||||
url = "{url}";"""
|
||||
|
||||
hash = subprocess.check_output(cmd, text=True).strip()
|
||||
|
||||
generated += f"""
|
||||
rev = "{rev}";
|
||||
hash = "{hash}";
|
||||
}};"""
|
||||
generated += subprocess.check_output(["nurl", url, rev, "--indent=4"], text=True)
|
||||
generated += ";"
|
||||
|
||||
location = info.get("location")
|
||||
if location:
|
||||
|
@ -101,12 +60,12 @@ def generate_grammar(item):
|
|||
|
||||
generated_file = """# generated by pkgs/applications/editors/vim/plugins/nvim-treesitter/update.py
|
||||
|
||||
{ buildGrammar, fetchFromGitHub, fetchFromGitLab, fetchgit }:
|
||||
{ buildGrammar, fetchFromGitHub, fetchFromGitLab, fetchFromSourcehut, fetchgit }:
|
||||
|
||||
{
|
||||
"""
|
||||
|
||||
for generated in map(generate_grammar, lockfile.items()):
|
||||
for generated in ThreadPoolExecutor().map(generate_grammar, lockfile.items()):
|
||||
generated_file += generated
|
||||
|
||||
generated_file += "}\n"
|
||||
|
|
37
pkgs/tools/misc/nurl/default.nix
Normal file
37
pkgs/tools/misc/nurl/default.nix
Normal file
|
@ -0,0 +1,37 @@
|
|||
{ lib
|
||||
, rustPlatform
|
||||
, fetchFromGitHub
|
||||
, makeWrapper
|
||||
, gitMinimal
|
||||
, mercurial
|
||||
, nix
|
||||
}:
|
||||
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "nurl";
|
||||
version = "0.1.1";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "nix-community";
|
||||
repo = "nurl";
|
||||
rev = "v${version}";
|
||||
hash = "sha256-dN53Xpb3zOVI6Xpi+RRFQPLIMP3+ATMXpYpFGgFpzPw=";
|
||||
};
|
||||
|
||||
cargoSha256 = "sha256-bdxHxLUeIPlRw7NKg0nTaDAkQam80eepqbuAmFVIMNs=";
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
|
||||
postInstall = ''
|
||||
wrapProgram $out/bin/nurl \
|
||||
--prefix PATH : ${lib.makeBinPath [ gitMinimal mercurial nix ]}
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "Command-line tool to generate Nix fetcher calls from repository URLs";
|
||||
homepage = "https://github.com/nix-community/nurl";
|
||||
changelog = "https://github.com/nix-community/nurl/blob/v${version}/CHANGELOG.md";
|
||||
license = licenses.mpl20;
|
||||
maintainers = with maintainers; [ figsoda ];
|
||||
};
|
||||
}
|
|
@ -10038,6 +10038,8 @@ with pkgs;
|
|||
|
||||
numlockx = callPackage ../tools/X11/numlockx { };
|
||||
|
||||
nurl = callPackage ../tools/misc/nurl { };
|
||||
|
||||
nttcp = callPackage ../tools/networking/nttcp { };
|
||||
|
||||
ntttcp = callPackage ../tools/networking/ntttcp { };
|
||||
|
|
Loading…
Reference in a new issue