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:
Erik Arvstedt 2023-01-06 10:28:52 +01:00
parent 95d770453d
commit 5339c7ccf1
No known key found for this signature in database
GPG key ID: 33312B944DD97846
4 changed files with 157 additions and 159 deletions

View file

@ -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 += ";"

View file

@ -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' //

View file

@ -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" ])