Oregami
Repositories/oxedyne/fe2o3

oxedyne/fe2o3/fe2o3_austenite/tools/gate/gate_lib.sh

1.2 KiB, 1 run

created by r1870400018:66266, which is this file's identity for as long as the history lasts, whatever it is later renamed to

download · who wrote it · its history

1# Sourced by the gate scripts. The one way they run a typst 0.15.x: under the memory cap, and with the
2# account's own fonts hidden. Typst looks for them under `$XDG_DATA_HOME/fonts`; a face installed there (a
3# second Libertinus Serif of another version, say) outranks Typst's own and would move a glyph on one side
4# only, so `XDG_DATA_HOME` names a directory that does not exist. This is the shell twin of
5# `typst_command` in `tests/eval_oracle/oracle.rs`.
6
7GATE_CAP="${GATE_CAP:-3G}"
8
9# Runs a command under the cap, in the claude-rc slice.
10gate_cap() {
11 systemd-run --user --scope --quiet -p "MemoryMax=${GATE_CAP}" --slice=claude-rc.slice "$@"
12}
13
14# gate_hidden <command> <args...>: a command under the cap with the account's own fonts hidden, as above.
15# GATE_SCRATCH names a directory that exists; its child `no-user-fonts` must not.
16gate_hidden() {
17 local none="${GATE_SCRATCH:?gate_hidden: no scratch}/no-user-fonts"
18 if [ -e "$none" ]; then
19 echo "gate_hidden: the font isolation directory exists" >&2
20 return 97
21 fi
22 XDG_DATA_HOME="$none" gate_cap "$@"
23}
24
25# gate_typst <typst> <args...>.
26gate_typst() {
27 local bin="${1:?gate_typst: no typst}"
28 shift
29 gate_hidden "$bin" "$@"
30}