Skip to content
Phaedrus Leeds edited this page Nov 18, 2021 · 4 revisions

Hints for shipping Flatpak

Flatpak is designed to be shipped as part of a Linux distribution.

Building Flatpak

See https://github.com/flatpak/flatpak/blob/master/CONTRIBUTING.md

Filesystem layout

This section is describing the default filesystem layout, assuming you haven't configured your build with a non-standard prefix or sysconfdir.

The default system installation is in /var/lib/flatpak, and you may want to include that directory in your package. Flatpak will create the necessary OSTree repo and other directories as necessary when it is run.

Flatpak will read static configuration in /etc/flatpak. You an predefine custom installations in /etc/flatpak/installations.d and remotes for the default system installation in /etc/flatpak/remotes.d, but it would be unusual for a distro package to do so.

Bash completion

Shell completion is an important aspect of the Flatpak commandline UX. It provides completion files for both bash and zsh.

Session setup

Flatpak relies on adding its installation locations to the XDG_DATA_DIRS environment variable to make desktop shells find flatpak apps. To this end, it installs a shell snipplet in /etc/profile.d and a systemd user environment generator in /usr/lib/systemd/user-environment-generators. Both of these should be included in distro packages.

Flatpak also relies on XDG_RUNTIME_DIR as the location for transient data, such as the document portal fuse mountpoint in $XDG_RUNTIME_DIR/doc, or the instance directories for running sandboxes in $XDG_RUNTIME_DIR/.flatpak. The typical location for XDG_RUNTIME_DIR is /run/user/$UID.

Other things to package

Flatpak applications rely on portals, so you should also package xdg-desktop-portal and one of the backends, xdg-desktop-portal-gtk or xdg-desktop-portal-kde. It is recommended that the installing flatpak should also make the portals available via hard or soft package dependencies.