diff --git a/pkgs/development/tools/parsing/tree-sitter/default.nix b/pkgs/development/tools/parsing/tree-sitter/default.nix index b56cd98da637..9495e331bd13 100644 --- a/pkgs/development/tools/parsing/tree-sitter/default.nix +++ b/pkgs/development/tools/parsing/tree-sitter/default.nix @@ -27,7 +27,8 @@ let # to update: # 1) change all these hashes # 2) nix-build -A tree-sitter.updater.update-all-grammars - # 3) run the ./result script that is output by that (it updates ./grammars) + # 3) OPTIONAL: Set GITHUB_TOKEN env variable to avoid api rate limit + # 4) run the ./result script that is output by that (it updates ./grammars) version = "0.20.1"; sha256 = "sha256-JKbL05hFWI0jhAnRT9D0SWCoRPFqoMD4+LQQ1zyWc7g="; cargoSha256 = "sha256-64O+3GrDqhRGth20B2/+jNDYSnwvT3SqYVqYNthiCB0="; diff --git a/pkgs/development/tools/parsing/tree-sitter/update.nix b/pkgs/development/tools/parsing/tree-sitter/update.nix index 58d420fe4028..19d29f4eaa10 100644 --- a/pkgs/development/tools/parsing/tree-sitter/update.nix +++ b/pkgs/development/tools/parsing/tree-sitter/update.nix @@ -360,9 +360,15 @@ let # generic bash script to find the latest github release for a repo latestGithubRelease = { orga, repo }: writeShellScript "latest-github-release" '' set -euo pipefail - res=$(${curl}/bin/curl \ - --silent \ - "https://api.github.com/repos/${urlEscape orga}/${urlEscape repo}/releases/latest") + + args=( '--silent' ) + if [ -n "$GITHUB_TOKEN" ]; then + args+=( "-H" "Authorization: token ''${GITHUB_TOKEN}" ) + fi + args+=( "https://api.github.com/repos/${urlEscape orga}/${urlEscape repo}/releases/latest" ) + + res=$(${curl}/bin/curl "''${args[@]}") + if [[ "$(printf "%s" "$res" | ${jq}/bin/jq '.message?')" =~ "rate limit" ]]; then echo "rate limited" >&2 fi @@ -378,9 +384,14 @@ let # find the latest repos of a github organization latestGithubRepos = { orga }: writeShellScript "latest-github-repos" '' set -euo pipefail - res=$(${curl}/bin/curl \ - --silent \ - 'https://api.github.com/orgs/${urlEscape orga}/repos?per_page=100') + + args=( '--silent' ) + if [ -n "$GITHUB_TOKEN" ]; then + args+=( "-H" "Authorization: token ''${GITHUB_TOKEN}" ) + fi + args+=( 'https://api.github.com/orgs/${urlEscape orga}/repos?per_page=100' ) + + res=$(${curl}/bin/curl "''${args[@]}") if [[ "$(printf "%s" "$res" | ${jq}/bin/jq '.message?')" =~ "rate limit" ]]; then echo "rate limited" >&2 #