tree-sitter/grammar: make fit for public use
- Rename `source` to the more idiomatic `src`. - Pass `version` to `mkDerivation` so that it's available in `drvAttrs`/`overrideAttrs`. - Remove misleading comment about `version`. (nvim-treesitter sets the version to the grammar src hash.)
This commit is contained in:
parent
95d770453d
commit
5339c7ccf1
4 changed files with 157 additions and 159 deletions
File diff suppressed because it is too large
Load diff
|
@ -36,7 +36,7 @@ def generate_grammar(item):
|
|||
generated = f""" {lang} = buildGrammar {{
|
||||
language = "{lang}";
|
||||
version = "{rev[:7]}";
|
||||
source = """
|
||||
src = """
|
||||
|
||||
generated += subprocess.check_output(["nurl", url, rev, "--indent=4"], text=True)
|
||||
generated += ";"
|
||||
|
|
|
@ -58,10 +58,10 @@ let
|
|||
let
|
||||
build = name: grammar:
|
||||
buildGrammar {
|
||||
language = if grammar ? language then grammar.language else name;
|
||||
language = grammar.language or name;
|
||||
inherit version;
|
||||
source = if grammar ? src then grammar.src else fetchGrammar grammar;
|
||||
location = if grammar ? location then grammar.location else null;
|
||||
src = grammar.src or fetchGrammar grammar;
|
||||
location = grammar.location or null;
|
||||
};
|
||||
grammars' = import ./grammars { inherit lib; } // extraGrammars;
|
||||
grammars = grammars' //
|
||||
|
|
|
@ -9,10 +9,8 @@
|
|||
{
|
||||
# language name
|
||||
language
|
||||
# version of tree-sitter
|
||||
, version
|
||||
# source for the language grammar
|
||||
, source
|
||||
, src
|
||||
, location ? null
|
||||
, generate ? false
|
||||
, ...
|
||||
|
@ -21,7 +19,7 @@
|
|||
stdenv.mkDerivation ({
|
||||
pname = "${language}-grammar";
|
||||
|
||||
src = source;
|
||||
inherit src version;
|
||||
|
||||
nativeBuildInputs = lib.optionals generate [ nodejs tree-sitter ];
|
||||
|
||||
|
@ -60,4 +58,4 @@ stdenv.mkDerivation ({
|
|||
fi
|
||||
runHook postInstall
|
||||
'';
|
||||
} // removeAttrs args [ "language" "source" "location" "generate" ])
|
||||
} // removeAttrs args [ "language" "location" "generate" ])
|
||||
|
|
Loading…
Reference in a new issue