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.
This commit is contained in:
@@ -405,14 +405,19 @@ let
|
||||
'';
|
||||
|
||||
# implementation of the fetching of repo information from github
|
||||
fetchImpl = writeShellScript "fetchImpl-wrapped" ''
|
||||
env ARGLIB_JSON=${lib.escapeShellArg (lib.generators.toJSON {} {
|
||||
fetchImpl = passBinaries "fetchImpl-wrapped" {
|
||||
curl = "${curl}/bin/curl";
|
||||
nix-prefetch-git = "${nix-prefetch-git}/bin/nix-prefetch-git";
|
||||
})} \
|
||||
${writers.writePython3 "fetchImpl" {
|
||||
flakeIgnore = ["E501"];
|
||||
} ./update_impl.py} "$@"
|
||||
}
|
||||
(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)} \
|
||||
${script} "$@"
|
||||
'';
|
||||
|
||||
foreachSh = attrs: f:
|
||||
|
||||
@@ -7,7 +7,7 @@ from typing import Generator, Any, Literal
|
||||
|
||||
debug: bool = True if os.environ.get("DEBUG", False) else False
|
||||
Bin = str
|
||||
bins: dict[str, Bin] = json.loads(os.environ['ARGLIB_JSON'])
|
||||
bins: dict[str, Bin] = json.loads(os.environ["BINARIES"])
|
||||
|
||||
mode: str = sys.argv[1]
|
||||
jsonArg: dict = json.loads(sys.argv[2])
|
||||
|
||||
Reference in New Issue
Block a user