tree-sitter/update: factor repo list into nix
We want the ability to add different orga repos as well, and that is a lot easier on the nix level.
This commit is contained in:
parent
a32c5d90e7
commit
d2988dac8e
|
@ -1,6 +1,6 @@
|
||||||
{ lib, stdenv
|
{ lib, stdenv
|
||||||
, fetchgit, fetchFromGitHub, fetchurl
|
, fetchgit, fetchFromGitHub, fetchurl
|
||||||
, writeShellScript, runCommand, which
|
, writeShellScript, runCommand, which, formats
|
||||||
, rustPlatform, jq, nix-prefetch-git, xe, curl, emscripten
|
, rustPlatform, jq, nix-prefetch-git, xe, curl, emscripten
|
||||||
, Security
|
, Security
|
||||||
, callPackage
|
, callPackage
|
||||||
|
@ -29,7 +29,7 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
update-all-grammars = import ./update.nix {
|
update-all-grammars = import ./update.nix {
|
||||||
inherit writeShellScript nix-prefetch-git curl jq xe src;
|
inherit writeShellScript nix-prefetch-git curl jq xe src formats;
|
||||||
};
|
};
|
||||||
|
|
||||||
fetchGrammar = (v: fetchgit {inherit (v) url rev sha256 fetchSubmodules; });
|
fetchGrammar = (v: fetchgit {inherit (v) url rev sha256 fetchSubmodules; });
|
||||||
|
|
|
@ -1,72 +1,80 @@
|
||||||
{ writeShellScript, nix-prefetch-git
|
{ writeShellScript, nix-prefetch-git, formats
|
||||||
, curl, jq, xe
|
, curl, jq, xe
|
||||||
, src }:
|
, src }:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
# Grammars we want to fetch from the tree-sitter github orga
|
||||||
|
knownTreeSitterOrgGrammarRepos = [
|
||||||
|
"tree-sitter-javascript"
|
||||||
|
"tree-sitter-c"
|
||||||
|
"tree-sitter-swift"
|
||||||
|
"tree-sitter-json"
|
||||||
|
"tree-sitter-cpp"
|
||||||
|
"tree-sitter-ruby"
|
||||||
|
"tree-sitter-razor"
|
||||||
|
"tree-sitter-go"
|
||||||
|
"tree-sitter-c-sharp"
|
||||||
|
"tree-sitter-python"
|
||||||
|
"tree-sitter-typescript"
|
||||||
|
"tree-sitter-rust"
|
||||||
|
"tree-sitter-bash"
|
||||||
|
"tree-sitter-php"
|
||||||
|
"tree-sitter-java"
|
||||||
|
"tree-sitter-scala"
|
||||||
|
"tree-sitter-ocaml"
|
||||||
|
"tree-sitter-julia"
|
||||||
|
"tree-sitter-agda"
|
||||||
|
"tree-sitter-fluent"
|
||||||
|
"tree-sitter-html"
|
||||||
|
"tree-sitter-haskell"
|
||||||
|
"tree-sitter-regex"
|
||||||
|
"tree-sitter-css"
|
||||||
|
"tree-sitter-verilog"
|
||||||
|
"tree-sitter-jsdoc"
|
||||||
|
"tree-sitter-ql"
|
||||||
|
"tree-sitter-embedded-template"
|
||||||
|
];
|
||||||
|
|
||||||
|
# repos of the tree-sitter github orga we want to ignore (not grammars)
|
||||||
|
ignoredTreeSitterOrgRepos = [
|
||||||
|
"tree-sitter"
|
||||||
|
"tree-sitter-cli"
|
||||||
|
# this is the haskell language bindings, tree-sitter-haskell is the grammar
|
||||||
|
"haskell-tree-sitter"
|
||||||
|
# this is the ruby language bindings, tree-sitter-ruby is the grammar
|
||||||
|
"ruby-tree-sitter"
|
||||||
|
# this is the (unmaintained) rust language bindings, tree-sitter-rust is the grammar
|
||||||
|
"rust-tree-sitter"
|
||||||
|
# this is the nodejs language bindings, tree-sitter-javascript is the grammar
|
||||||
|
"node-tree-sitter"
|
||||||
|
# this is the python language bindings, tree-sitter-python is the grammar
|
||||||
|
"py-tree-sitter"
|
||||||
|
# afl fuzzing for tree sitter
|
||||||
|
"afl-tree-sitter"
|
||||||
|
# archived
|
||||||
|
"highlight-schema"
|
||||||
|
# website
|
||||||
|
"tree-sitter.github.io"
|
||||||
|
];
|
||||||
|
|
||||||
|
jsonFile = name: val: (formats.json {}).generate name val;
|
||||||
|
|
||||||
# check in the list of grammars, whether we know all of them.
|
# check in the list of grammars, whether we know all of them.
|
||||||
checkKnownGrammars = writeShellScript "get-grammars.sh" ''
|
checkKnownGrammars = writeShellScript "get-grammars.sh" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
known='
|
known="${jsonFile "known-tree-sitter-org-grammar-repos" knownTreeSitterOrgGrammarRepos}"
|
||||||
[ "tree-sitter-javascript"
|
ignore="${jsonFile "ignored-tree-sitter-org-repos" ignoredTreeSitterOrgRepos}"
|
||||||
, "tree-sitter-c"
|
|
||||||
, "tree-sitter-swift"
|
|
||||||
, "tree-sitter-json"
|
|
||||||
, "tree-sitter-cpp"
|
|
||||||
, "tree-sitter-ruby"
|
|
||||||
, "tree-sitter-razor"
|
|
||||||
, "tree-sitter-go"
|
|
||||||
, "tree-sitter-c-sharp"
|
|
||||||
, "tree-sitter-python"
|
|
||||||
, "tree-sitter-typescript"
|
|
||||||
, "tree-sitter-rust"
|
|
||||||
, "tree-sitter-bash"
|
|
||||||
, "tree-sitter-php"
|
|
||||||
, "tree-sitter-java"
|
|
||||||
, "tree-sitter-scala"
|
|
||||||
, "tree-sitter-ocaml"
|
|
||||||
, "tree-sitter-julia"
|
|
||||||
, "tree-sitter-agda"
|
|
||||||
, "tree-sitter-fluent"
|
|
||||||
, "tree-sitter-html"
|
|
||||||
, "tree-sitter-haskell"
|
|
||||||
, "tree-sitter-regex"
|
|
||||||
, "tree-sitter-css"
|
|
||||||
, "tree-sitter-verilog"
|
|
||||||
, "tree-sitter-jsdoc"
|
|
||||||
, "tree-sitter-ql"
|
|
||||||
, "tree-sitter-embedded-template"
|
|
||||||
]'
|
|
||||||
ignore='
|
|
||||||
[ "tree-sitter"
|
|
||||||
, "tree-sitter-cli"
|
|
||||||
${/*this is the haskell language bindings, tree-sitter-haskell is the grammar*/""}
|
|
||||||
, "haskell-tree-sitter"
|
|
||||||
${/*this is the ruby language bindings, tree-sitter-ruby is the grammar*/""}
|
|
||||||
, "ruby-tree-sitter"
|
|
||||||
${/*this is the (unmaintained) rust language bindings, tree-sitter-rust is the grammar*/""}
|
|
||||||
, "rust-tree-sitter"
|
|
||||||
${/*this is the nodejs language bindings, tree-sitter-javascript is the grammar*/""}
|
|
||||||
, "node-tree-sitter"
|
|
||||||
${/*this is the python language bindings, tree-sitter-python is the grammar*/""}
|
|
||||||
, "py-tree-sitter"
|
|
||||||
${/*afl fuzzing for tree sitter*/""}
|
|
||||||
, "afl-tree-sitter"
|
|
||||||
${/*archived*/""}
|
|
||||||
, "highlight-schema"
|
|
||||||
${/*website*/""}
|
|
||||||
, "tree-sitter.github.io"
|
|
||||||
]'
|
|
||||||
res=$(${jq}/bin/jq \
|
res=$(${jq}/bin/jq \
|
||||||
--argjson known "$known" \
|
--slurpfile known "$known" \
|
||||||
--argjson ignore "$ignore" \
|
--slurpfile ignore "$ignore" \
|
||||||
'. - ($known + $ignore)' \
|
'. - ($known[0] + $ignore[0])' \
|
||||||
)
|
)
|
||||||
if [ ! "$res" == "[]" ]; then
|
if [ ! "$res" == "[]" ]; then
|
||||||
echo "These repositories are neither known nor ignored:" 1>&2
|
echo "These repositories are neither known nor ignored:" 1>&2
|
||||||
echo "$res" 1>&2
|
echo "$res" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
printf '%s' "$known"
|
cat "$known"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
|
|
Loading…
Reference in New Issue