lol

tree-sitter/update: ARGLIB_JSON -> BINARIES, factor out wrapper

arglib is a term I coined for passing arguments as structured
environment variable, but in this case it’s probably easier to
understand if we just call it `BINARIES`.

Factors out the code that passes the environment to another script.

+12 -7
+11 -6
pkgs/development/tools/parsing/tree-sitter/update.nix
··· 405 405 ''; 406 406 407 407 # implementation of the fetching of repo information from github 408 - fetchImpl = writeShellScript "fetchImpl-wrapped" '' 409 - env ARGLIB_JSON=${lib.escapeShellArg (lib.generators.toJSON {} { 408 + fetchImpl = passBinaries "fetchImpl-wrapped" { 410 409 curl = "${curl}/bin/curl"; 411 410 nix-prefetch-git = "${nix-prefetch-git}/bin/nix-prefetch-git"; 412 - })} \ 413 - ${writers.writePython3 "fetchImpl" { 414 - flakeIgnore = ["E501"]; 415 - } ./update_impl.py} "$@" 411 + } 412 + (writers.writePython3 "fetchImpl" { 413 + flakeIgnore = ["E501"]; 414 + } ./update_impl.py); 415 + 416 + # Pass the given binaries to the command, in the BINARIES environment variable. 417 + # The binaries are just an attrset from name to executable. 418 + passBinaries = name: binAttrs: script: writeShellScript name '' 419 + env BINARIES=${lib.escapeShellArg (lib.generators.toJSON {} binAttrs)} \ 420 + ${script} "$@" 416 421 ''; 417 422 418 423 foreachSh = attrs: f:
+1 -1
pkgs/development/tools/parsing/tree-sitter/update_impl.py
··· 7 7 8 8 debug: bool = True if os.environ.get("DEBUG", False) else False 9 9 Bin = str 10 - bins: dict[str, Bin] = json.loads(os.environ['ARGLIB_JSON']) 10 + bins: dict[str, Bin] = json.loads(os.environ["BINARIES"]) 11 11 12 12 mode: str = sys.argv[1] 13 13 jsonArg: dict = json.loads(sys.argv[2])