The dev shell (guix shell -D) has the full toolchain and network, so the build happens there. The isolated 'guix shell -C -N' container only runs the already-compiled binary, which needs just the GTK/WebKit C libraries via LD_LIBRARY_PATH. Also export WEBKIT_DISABLE_COMPOSITING_MODE and WEBKIT_DISABLE_DMABUF_RENDERER, without which WebKit renders a blank surface inside the sandbox. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
41 lines
1.8 KiB
Shell
Executable file
41 lines
1.8 KiB
Shell
Executable file
#!/bin/sh
|
|
set -e
|
|
|
|
BOOK_PATH="/home/user/static/3-I/books/delayed-call-toni-aleo.epub"
|
|
|
|
mkdir -p /tmp/guix-dbus
|
|
echo "00000000000000000000000000000000" > /tmp/guix-dbus/machine-id
|
|
|
|
# --- Build outside the container ---------------------------------------------
|
|
# The dev shell has the full toolchain and needs no display. --offline reuses
|
|
# the cached build plan + package store (~/.local/state/cabal), so no hackage
|
|
# index or network is required. GHC_PACKAGE_PATH must be unset for cabal.
|
|
BUILD='unset GHC_PACKAGE_PATH; cabal build --offline svitak'
|
|
guix shell -D -f guix.scm -- sh -c "$BUILD"
|
|
SVITAK_BIN=$(guix shell -D -f guix.scm -- sh -c 'unset GHC_PACKAGE_PATH; cabal list-bin --offline svitak')
|
|
|
|
# --- Run inside the container ------------------------------------------------
|
|
# The compiled binary statically links its Haskell deps; it only needs the C
|
|
# libraries (GTK/WebKit) from the guix profile via LD_LIBRARY_PATH, plus the
|
|
# Wayland/D-Bus sockets shared below. No cabal at runtime.
|
|
guix shell -C -N --emulate-fhs \
|
|
--share=$PWD=$PWD \
|
|
--share="$HOME/static/3-I/books"="$HOME/static/3-I/books" \
|
|
--share="$XDG_RUNTIME_DIR"="$XDG_RUNTIME_DIR" \
|
|
--share="$XDG_RUNTIME_DIR/bus"="$XDG_RUNTIME_DIR/bus" \
|
|
--share=/tmp/guix-dbus/machine-id=/etc/machine-id \
|
|
--share=/dev/dri \
|
|
--share=/sys \
|
|
--preserve='^WAYLAND_DISPLAY$' \
|
|
--preserve='^XDG_RUNTIME_DIR$' \
|
|
--preserve='^DBUS_SESSION_BUS_ADDRESS$' \
|
|
-D -f guix.scm -- \
|
|
bash -c "export LD_LIBRARY_PATH=\$GUIX_ENVIRONMENT/lib:\$LD_LIBRARY_PATH
|
|
export GI_TYPELIB_PATH=\$GUIX_ENVIRONMENT/lib/girepository-1.0:\$GI_TYPELIB_PATH
|
|
|
|
# WebKitGTK renders a blank/white surface inside the sandboxed container
|
|
# unless its GPU compositing + DMABUF renderer are disabled.
|
|
export WEBKIT_DISABLE_COMPOSITING_MODE=1
|
|
export WEBKIT_DISABLE_DMABUF_RENDERER=1
|
|
|
|
\"$SVITAK_BIN\" \"$BOOK_PATH\""
|