diff options
author | Profpatsch <mail@profpatsch.de> | 2022-09-12 13:02:10 +0200 |
---|---|---|
committer | Profpatsch <mail@profpatsch.de> | 2022-11-04 18:14:33 +0100 |
commit | 923975a604e5de29106dfe349dc5b6576b6045b6 (patch) | |
tree | 15d45b5f179495727df9fd3084da9db6ef85842c | |
parent | aa480ba1111f61e3774e2bd3b686c3e890955b04 (diff) |
tree-sitter/update: BINARIES -> ARGS.binaries
I want to pass more information in the next step, so binaries are just one of multiple elements of the json value. Generate a json file via `format` so that we get nicer formatting (`lib.generators.toJSON` uses `builtins.toJSON` which does not add any whitespace).
-rw-r--r-- | pkgs/development/tools/parsing/tree-sitter/update.nix | 18 | ||||
-rw-r--r-- | pkgs/development/tools/parsing/tree-sitter/update_impl.py | 3 |
2 files changed, 12 insertions, 9 deletions
diff --git a/pkgs/development/tools/parsing/tree-sitter/update.nix b/pkgs/development/tools/parsing/tree-sitter/update.nix index b9d4a0131633e..a51208a5bfde7 100644 --- a/pkgs/development/tools/parsing/tree-sitter/update.nix +++ b/pkgs/development/tools/parsing/tree-sitter/update.nix @@ -405,19 +405,21 @@ let ''; # implementation of the fetching of repo information from github - fetchImpl = passBinaries "fetchImpl-wrapped" { - curl = "${curl}/bin/curl"; - nix-prefetch-git = "${nix-prefetch-git}/bin/nix-prefetch-git"; - inherit atomically-write; + fetchImpl = passArgs "fetchImpl-with-args" { + binaries = { + curl = "${curl}/bin/curl"; + nix-prefetch-git = "${nix-prefetch-git}/bin/nix-prefetch-git"; + inherit atomically-write; + }; } (writers.writePython3 "fetchImpl" { flakeIgnore = ["E501"]; } ./update_impl.py); - # Pass the given binaries to the command, in the BINARIES environment variable. - # The binaries are just an attrset from name to executable. - passBinaries = name: binAttrs: script: writeShellScript name '' - env BINARIES=${lib.escapeShellArg (lib.generators.toJSON {} binAttrs)} \ + # Pass the given arguments to the command, in the ARGS environment variable. + # The arguments are just a json object that should be available in the script. + passArgs = name: argAttrs: script: writeShellScript name '' + env ARGS="$(< ${jsonFile "${name}-args" argAttrs})" \ ${script} "$@" ''; diff --git a/pkgs/development/tools/parsing/tree-sitter/update_impl.py b/pkgs/development/tools/parsing/tree-sitter/update_impl.py index 1e2edd0944b42..1bff7aac1abfb 100644 --- a/pkgs/development/tools/parsing/tree-sitter/update_impl.py +++ b/pkgs/development/tools/parsing/tree-sitter/update_impl.py @@ -7,7 +7,8 @@ from typing import Iterator, Any, Literal debug: bool = True if os.environ.get("DEBUG", False) else False Bin = str -bins: dict[str, Bin] = json.loads(os.environ["BINARIES"]) +args: dict[str, Any] = json.loads(os.environ["ARGS"]) +bins: dict[str, Bin] = args["binaries"] mode: str = sys.argv[1] jsonArg: dict = json.loads(sys.argv[2]) |