uvms: support args in app urls

This commit is contained in:
Else Someone 2026-03-15 01:30:18 +02:00
parent 42fca62474
commit a13e9c9393

View file

@ -13,7 +13,7 @@ import json
import re import re
from argparse import ArgumentParser from argparse import ArgumentParser
from contextlib import contextmanager, closing, ExitStack from contextlib import contextmanager, closing, ExitStack
from urllib import urlparse from urllib.parse import urlparse, parse_qs
parser = ArgumentParser("supervise-vm") parser = ArgumentParser("supervise-vm")
@ -519,16 +519,21 @@ def main(args, args_next, cleanup, ps):
app_paths = [] app_paths = []
for a in args.app: for a in args.app:
a = urlparse(a) a = urlparse(a)
nix_file = None nix_file = "./."
attr = None attr = None
if a.scheme == "": if a.scheme == "":
nix_file = "<nixpkgs>" nix_file = "<nixpkgs>"
attr = a.path attr = a.path
elif a.scheme == "getexe":
nix_file = a.netloc or "./."
attr = a.path.lstrip("/")
else: else:
raise RuntimeError("Unknown app url", a) assert a.fragment, a
attr = a.fragment
nix_file = a.path or "./."
arglist = []
for k, v in parse_qs(a.query).items():
arglist.append("--arg")
arglist.append(k)
arglist.append(v)
assert nix_file is not None, a assert nix_file is not None, a
assert attr is not None, a assert attr is not None, a
out_path = ps.exec( out_path = ps.exec(
@ -536,7 +541,9 @@ def main(args, args_next, cleanup, ps):
nix_file, nix_file,
"-A", "-A",
attr, attr,
*arglist,
"--no-out-link", "--no-out-link",
cwd=os.getcwd(),
capture_output=True, capture_output=True,
text=True, text=True,
).stdout.strip() ).stdout.strip()