refactor: move out large code blocks out of nix

This commit is contained in:
fufsob authored and FUFSoB committed 2026-10-04 11:54:04 +05:00
1 parent e8ace6523d
commit af5b3ff27a
47 files changed
+2220 -2070

No files matched your search

+7 -31
View File
@@ -8,6 +8,7 @@
system:
let
fillTemplate = import ../modules/proxy-suite/lib/fill-template.nix;
pkgs = pkgsFor system;
packages = import ../pkgs/default.nix { inherit pkgs; };
fixture = import ./readme-doc-fixture.nix;
@@ -32,34 +33,9 @@ let
context
;
in
pkgs.runCommand "proxy-suite-README.md" { nativeBuildInputs = [ pkgs.python3 ]; } ''
src=${../README.md}
help_file="$TMPDIR/proxy-ctl-help.txt"
export src help_file
${context.control.proxyCtl}/bin/proxy-ctl help > "$help_file"
python <<'PY'
from pathlib import Path
import os
src = Path(os.environ["src"])
help_file = Path(os.environ["help_file"])
out = Path(os.environ["out"])
start_marker = "<!-- proxy-ctl-help:start -->"
end_marker = "<!-- proxy-ctl-help:end -->"
readme = src.read_text()
help_text = help_file.read_text().rstrip("\n")
replacement = f"{start_marker}\n```text\n{help_text}\n```\n{end_marker}"
try:
start = readme.index(start_marker)
end = readme.index(end_marker) + len(end_marker)
except ValueError as exc:
raise SystemExit(f"README markers missing: {exc}")
out.write_text(readme[:start] + replacement + readme[end:])
PY
''
pkgs.runCommand "proxy-suite-README.md" { nativeBuildInputs = [ pkgs.python3 ]; } (
fillTemplate ./readme-doc.template.sh {
readme = ../README.md;
proxyCtl = context.control.proxyCtl;
}
)