diff --git a/run-svitak.sh b/run-svitak.sh index ba7084f..6410ede 100755 --- a/run-svitak.sh +++ b/run-svitak.sh @@ -1,14 +1,26 @@ #!/bin/sh +set -e -BOOK_PATH="" +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=$HOME/.cabal=$HOME/.cabal \ --share=$PWD=$PWD \ - --share="$HOME/3-I/books"="$HOME/3-I/books" \ + --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 \ @@ -21,7 +33,9 @@ guix shell -C -N --emulate-fhs \ 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 - echo \"LD_LIBRARY_PATH is: \$LD_LIBRARY_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 - cabal clean - cabal run svitak -- \"$BOOK_PATH\"" + \"$SVITAK_BIN\" \"$BOOK_PATH\""