Add a web browser tab.

This commit is contained in:
Greyson Parrelli
2026-08-11 12:39:14 -04:00
parent 918ccec6e1
commit a7a9429d09
12 changed files with 868 additions and 93 deletions
+41 -16
View File
@@ -38,10 +38,16 @@ gcroots="$data/vtabs/gcroots"
# The binary carries an RPATH into the Nix store, so it runs anywhere, but it
# still has to be told where GTK's GSettings schemas and icon themes live or
# it aborts on a missing schema. Read those paths back out of the dev shell
# that built it rather than hardcoding store hashes.
# it aborts on a missing schema, where GIO's TLS module lives or every
# https:// page in a web pane fails, and which mesa to render web panes
# through or WebKit's web process dies on startup. Read those paths back out
# of the dev shell that built it rather than hardcoding store hashes.
schemas="$(nix develop --command printenv VTABS_GSETTINGS_SCHEMA_DIR)"
datadirs="$(nix develop --command printenv VTABS_RUNTIME_DATA_DIRS)"
giomodules="$(nix develop --command printenv VTABS_GIO_MODULE_DIR)"
eglvendor="$(nix develop --command printenv VTABS_EGL_VENDOR_DIR)"
dridrivers="$(nix develop --command printenv VTABS_DRI_DRIVERS_PATH)"
gbmbackends="$(nix develop --command printenv VTABS_GBM_BACKENDS_PATH)"
mkdir -p "$bindir" "$libexec" "$apps" "$icons" "$gcroots"
@@ -55,6 +61,15 @@ cat > "$bindir/vtabs" <<EOF
# Generated by \`mise run install\` — re-run that instead of editing.
export GSETTINGS_SCHEMA_DIR="$schemas\${GSETTINGS_SCHEMA_DIR:+:\$GSETTINGS_SCHEMA_DIR}"
export XDG_DATA_DIRS="$datadirs:\${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
export GIO_EXTRA_MODULES="$giomodules\${GIO_EXTRA_MODULES:+:\$GIO_EXTRA_MODULES}"
# Web panes render through the mesa this was built against. Mixing it with
# the host's mesa aborts WebKit's web process, so these are set outright
# rather than appended to whatever the session already had.
export __EGL_VENDOR_LIBRARY_DIRS="$eglvendor"
export LIBGL_DRIVERS_PATH="$dridrivers"
export GBM_BACKENDS_PATH="$gbmbackends"
exec "$libexec/vtabs" "\$@"
EOF
chmod 755 "$bindir/vtabs"
@@ -68,20 +83,30 @@ install -m644 dist/dev.greyson.vtabs.svg "$icons/dev.greyson.vtabs.svg"
# starting, with no obvious connection to the command that broke it.
# Nix roots are transitive, so rooting each RPATH entry covers its closure.
rm -f "$gcroots"/*
if command -v readelf >/dev/null; then
readelf -d "$libexec/vtabs" \
| sed -n 's/.*R\(UN\)\?PATH.*\[\(.*\)\]/\2/p' \
| tr ':' '\n' \
| sed -n 's|^\(/nix/store/[^/]*\).*|\1|p' \
| sort -u \
| while read -r path; do
nix-store --realise --add-root "$gcroots/$(basename "$path")" \
--indirect "$path" >/dev/null 2>&1 || true
done
echo "pinned $(find "$gcroots" -maxdepth 1 -type l | wc -l) store paths against garbage collection"
else
echo "warning: readelf not found; store paths left unpinned (nix-collect-garbage may break the install)" >&2
fi
{
# What the dynamic linker needs, read straight out of the binary.
if command -v readelf >/dev/null; then
readelf -d "$libexec/vtabs" \
| sed -n 's/.*R\(UN\)\?PATH.*\[\(.*\)\]/\2/p' \
| tr ':' '\n'
else
echo "warning: readelf not found; only the launcher's own paths are pinned" >&2
fi
# What the launcher points at. These are opened by name at runtime rather
# than linked, so they never show up in the RPATH and would otherwise be
# left for the collector — losing the TLS module breaks https in web panes
# long after the command that deleted it.
printf '%s\n' "$schemas" "$datadirs" "$giomodules" \
"$eglvendor" "$dridrivers" "$gbmbackends" | tr ':' '\n'
} \
| sed -n 's|^\(/nix/store/[^/]*\).*|\1|p' \
| sort -u \
| while read -r path; do
nix-store --realise --add-root "$gcroots/$(basename "$path")" \
--indirect "$path" >/dev/null 2>&1 || true
done
echo "pinned $(find "$gcroots" -maxdepth 1 -type l | wc -l) store paths against garbage collection"
# Let the desktop notice the new entry and icon right away.
command -v update-desktop-database >/dev/null && update-desktop-database -q "$apps" || true