# yml for flatpak
# v1.0 John Harrison john.harrison@alum.mit.edu Dec-2025
# prep for flatpak:
# sudo apt install flatpak flatpak-builder
# flatpak install flathub org.freedesktop.Platform//24.08 org.freedesktop.Sdk//24.08
# to create: flatpak-builder --repo=repo --force-clean --state-dir=build-cache-arsandbox build-dir-arsandbox org.arsandboxg.ARSandbox.yml
# then bundle as one file: flatpak build-bundle repo arsandbox_g.flatpak org.arsandboxg.ARSandbox
app-id: org.arsandboxg.ARSandbox
runtime: org.freedesktop.Platform
runtime-version: '24.08' # latest stable Dec 2025
sdk: org.freedesktop.Sdk
command: SARndbox
finish-args: # permissions i.e. "holes" in the sandbox
- --share=ipc # high-speed video data transfer via shared memory
- --socket=x11 # access to X11
- --socket=wayland # access to Wayland
- --device=all # access to all devices including the Kinect USB and the GPU
- --filesystem=host # allows file write to host filesystem so we can save config files
build-options:
env:
# where will we find the .pc (package config) files?
# /usr/share/pkgconfig and /usr/lib/pkgconfig are "boilerplate" so always have those
# these map to the flatpak SDK i.e. /var/lib/flatpak/runtime/org.freedesktop.Sdk OR
# ~/.local/share/flatpak/runtime/org.freedesktop.Sdk depending on how Flatpak was installed
# /app/lib/pkgconfig magically maps to /build-dir/arsandbox/files/lib/pkgconfig and
# is required for libusb and vrui since those are built as part of the flatpak
# when builds fail look for the .pc files inside this flatpak files directory
PKG_CONFIG_PATH: /app/lib/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig
modules:
- name: libusb
buildsystem: autotools # libusb had a configure.ac file which is a giveaway for autocools
# this basically means we follow the pattern: ./configure && make && make install
config-opts:
- --prefix=/app # boilerplate. Without this make install would try to install into /usr/local
# which doesn't exist for a flatpak
- --disable-static # flatpak doesn't like static libraries apparently so consider this boilerplate
sources:
- type: git
url: https://github.com/libusb/libusb.git
tag: v1.0.26
- name: vrui
buildsystem: simple # all we had to work with was a makefile so we need to give exact commands to build
build-commands:
# Run config to generate Config.h files:
# libusb was installed in /app (see above)
# libext defaults to /lib64 on 64 bit systems but flatpak uses /lib. libext is a custom name in vrui
# you can find that custom name in BuildRoot/SystemDefinitions
# installdir is boilerplate. Put everything in /app
# SYSTEM_HAVE_LIBDBUS was to fix a comopiler error. This was used to inhibit the screensaver only
# so it seemed not worth trying to fix the compiler error for this
- make config LIBUSB1_BASEDIR=/app LIBEXT=lib SYSTEM_HAVE_LIBDBUS=0 INSTALLDIR=/app
# Disable DC1394 (FireWire camera) support since it was giving errors in compile and we didn't need 1394.
- sed -i 's/SYSTEM_HAVE_DC1394 = 1/SYSTEM_HAVE_DC1394 = 0/g' BuildRoot/Configuration.Vrui
- sed -i 's/#define VIDEO_CONFIG_HAVE_DC1394 1/#define VIDEO_CONFIG_HAVE_DC1394 0/g' Video/Config.h
# Build
- make -j${FLATPAK_BUILDER_N_JOBS} LIBUSB1_BASEDIR=/app LIBEXT=lib SYSTEM_HAVE_LIBDBUS=0 INSTALLDIR=/app
# Install
- make install LIBUSB1_BASEDIR=/app LIBEXT=lib SYSTEM_HAVE_LIBDBUS=0 INSTALLDIR=/app
sources:
- type: git
url: https://github.com/vrui-vr/Vrui.git
branch: main
- name: kinect
buildsystem: simple
# figure out the below make flags with `flatpak-builder --run build-dir-arsandbox org.arsandboxg.ARSandbox.yml sh`
build-commands:
- make VRUI_MAKEDIR=/app/share/Vrui-14.0/make VRUI_INCLUDEDIR=/app/include/Vrui-14.0 VRUI_LIBDIR=/app/lib/Vrui-14.0 LIBUSB1_BASEDIR=/app LIBEXT=lib INSTALLDIR=/app
- make install VRUI_MAKEDIR=/app/share/Vrui-14.0/make VRUI_INCLUDEDIR=/app/include/Vrui-14.0 VRUI_LIBDIR=/app/lib/Vrui-14.0 LIBUSB1_BASEDIR=/app LIBEXT=lib INSTALLDIR=/app
sources:
- type: git
url: https://github.com/vrui-vr/Kinect.git
branch: main
- name: arsandbox
buildsystem: simple
build-commands:
# Run config first to generate Config.h
- make config VRUI_MAKEDIR=/app/share/Vrui-14.0/make VRUI_INCLUDEDIR=/app/include/Vrui-14.0 VRUI_LIBDIR=/app/lib/Vrui-14.0 LIBUSB1_BASEDIR=/app LIBEXT=lib INSTALLDIR=/app
# Patch Config.h to use dynamic configuration directory AND copy defaults if missing
# if would be better if code was fix but for now we "soft patch"
# note use of - l for list so yaml parser doesn't get confused with backslash n
- |
sed -i '1i #include <stdlib.h>\n#include <string>\n#include <sys/stat.h>\n#include <unistd.h>\nstatic std::string getConfigDir() {\n const char* xdg = getenv("XDG_CONFIG_HOME");\n std::string dir;\n if(xdg) dir = std::string(xdg) + "/SARndbox-5.0";\n else { const char* home = getenv("HOME"); if(home) dir = std::string(home) + "/.config/SARndbox-5.0"; else return "/app/etc/SARndbox-5.0"; }\n mkdir(dir.c_str(), 0755);\n std::string test = dir + "/SARndbox.cfg";\n if(access(test.c_str(), F_OK) != 0) { std::string cmd = "cp -n /app/etc/SARndbox-5.0/* " + dir; int ret = system(cmd.c_str()); (void)ret; }\n return dir;\n}' Config.h
- sed -i 's|#define CONFIG_CONFIGDIR .*|#define CONFIG_CONFIGDIR getConfigDir().c_str()|' Config.h
# Patch Water2WaterUpdateShader.fs to fix read-only variable assignment
# really this should be fixed in the source code as well
- sed -i 's/snowMelt=min(snowMelt,s);/float meltAmount=min(snowMelt,s);/g' share/Shaders/Water2WaterUpdateShader.fs
- sed -i 's/dSnow=dSnow-snowMelt;/dSnow=dSnow-meltAmount;/g' share/Shaders/Water2WaterUpdateShader.fs
- sed -i 's/dWater=dWater+snowMelt\/4.0;/dWater=dWater+meltAmount\/4.0;/g' share/Shaders/Water2WaterUpdateShader.fs
# Build and Install
- make VRUI_MAKEDIR=/app/share/Vrui-14.0/make VRUI_INCLUDEDIR=/app/include/Vrui-14.0 VRUI_LIBDIR=/app/lib/Vrui-14.0 LIBUSB1_BASEDIR=/app LIBEXT=lib INSTALLDIR=/app
- make install VRUI_MAKEDIR=/app/share/Vrui-14.0/make VRUI_INCLUDEDIR=/app/include/Vrui-14.0 VRUI_LIBDIR=/app/lib/Vrui-14.0 LIBUSB1_BASEDIR=/app LIBEXT=lib INSTALLDIR=/app
sources:
- type: git
url: https://github.com/vrui-vr/arsandbox.git
branch: main