Flatpak is a package management framework aiming to provide support for sandboxed, distro-agnostic binary packages for Linux desktop applications. Just as chroot, Docker, and LXD provide a means to isolate primarily server-based applications from the underlying operating system, Flatpak provides a mechanism to isolate primarily desktop-based applications from the underlying operating system. When combined with features like systemd-homed, it becomes possible to contain a user and all of that user's applications within a single directory, the user's $HOME, in a manner that is portable across systems of the same CPU architecture.
USE flags for sys-apps/flatpak Linux application sandboxing and distribution framework
||Add support for X11|
||Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally|
||Add support for GObject based introspection|
||Enable PolicyKit (polkit) authentication support|
||Enable seccomp (secure computing mode) to perform system call filtering at runtime to increase security of programs|
||Enable use of systemd-specific libraries and features like socket activation or session tracking|
Chromium-based browsers suggest disabling the
suidUSE flag for sys-apps/bubblewrap for performance reasons. Also there are technologies such as Valve Pressure Vessel (used in Steam) which requires it to work. Without
suid, bubblewrap requires the kernel option
CONFIG_USER_NS=yto be set.
Flatpak installation guide suggested to restart the system after installation. This might be no longer necessary.
emerge --ask sys-apps/flatpak
Add flathub repository
All operations with flatpak can be performed as user or as root, if performing as user --user flag can help if there are issues with permissions.
flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
- /var/lib/flatpak — global flatpak state (system-wide installed apps and repos)
- $HOME/.local/share/flatpak — per-user flatpak state (locally installed apps and repos)
- $HOME/.var/app/ — per application state (configuration files and cache)
In some instances, it may be necessary to edit the sandbox permissions of a flatpak application. The most convenient way of doing this is via the GUI tool Flatseal.
flatpak install com.github.tchx84.Flatseal
To install an application, e.g. Thunderbird, run:
flatpak --user install org.mozilla.Thunderbird
To run the application use created .desktop file or run:
flatpak run org.mozilla.Thunderbird
To update installed applications and runtimes:
Flatpak documentiation offers a good guide about desktop integration and theming.
Flatpak applications don't follow the system's GTK theme by default. First find out what's the current GTK theme, e.g. Materia-dark-compact, and then install it for Flatpak applications to use. 
gsettings get org.gnome.desktop.interface gtk-theme
flatpak install flathub org.gtk.Gtk3theme.Materia-dark-compact
Desktop integration for Wayland
When using WMs such as Sway, installing xdg portals is needed for full integration. There are backends available for this matter:
- GTK backend: 'xdg-desktop-portal-gtk'
- KDE backend 'xdg-desktop-portal-kde' (in development)
- Wayland/wlroots backend: 'xdg-desktop-portal-wlr' (in development)
- LXQt backend 'xdg-desktop-portal-lxqt' (in development)
- Flatpak backend: 'flatpak-portal' (included in the Flatpak package)
Please note that these are separate entities that do not substitute each other and some of them may not be run at the same time as some of the others.
First, emerge sys-apps/xdg-desktop-portal:
emerge --ask sys-apps/xdg-desktop-portal
Then emerge any needed backends:
emerge --ask sys-apps/xdg-desktop-portal-gtk sys-apps/xdg-desktop-portal-wlr gui-libs/xdg-desktop-portal-lxqt sys-apps/xdg-desktop-portal-gnome
Desktop environment backends such as
xdg-desktop-portal-lxqtmay be installed by default depending on how the desktop environment was installed
Ensuring portals are running
Please note that sometimes these libraries aren't pulled automatically by the OS and need to be run by the user, for example they can be pulled in Sway configuration:
exec /usr/libexec/xdg-desktop-portal-gtk -r exec /usr/libexec/xdg-desktop-portal-wlr -r exec /usr/libexec/flatpak-portal -r exec "sh -c 'sleep 5;exec /usr/libexec/xdg-desktop-portal -r'"
After updating nvidia-drivers 3D applications crash or become slow
Make sure to update the flatpak nvidia platform.
Flatpaked GTK apps under Wayland and jagged fonts
Some users report jagged fonts on Wayland. This happens because if GTK apps can't detect whether they should perform font antialiasing, they disable ones by default. It obtain info ether from the system or via
xdg-desktop-portal-gtk if flatpaked. It also requires setting up the proper wayland scheme for it from
gnome-base/gsettings-desktop-schemas, but that package already in list of flatpak dependencies.
So a workaround is to install
xdg-desktop-portal-gtk and reboot/restart the desktop:
emerge --ask sys-apps/xdg-desktop-portal-gtk
To make sure if it is launched, see "Ensuring portals are running" topic above.
Since in early 2022 GTK wayland schemas are moved from
gnome-base/gsettings-desktop-schemas, the gnome settings daemon is no more required and can be uninstalled.
Certain flatpak applications failing to access proper cursor
Some flatpaks such as
com.spotify.Client have an issue where they cannot find the systems cursor, and so default to the ugly default cursor that is used when no proper replacement is found.
A solution to this is to copy the systems icon directory to a location in the users home directory. In this example
~/.local/share/icons will be used:
/usr/share/iconsis one of the several directories icons can be used from. You could also use
cp -r /usr/share/icons ~/.local/share/
flatpak-override to give the flatpak in question (com.discordapp.Discord in this example) access to the home directory in which the cursors are inside:
flatpak override --filesystem=home com.discordapp.Discord
To remove the filesystem override, run:
flatpak override --nofilesystem=home com.discordapp.Discord
After the filesystem override is set, the
XCURSOR_THEME variables must be set, where
XCURSOR_PATH is the path to the theme and
XCURSOR_PATH is the name of the theme like so:
flatpak override --env=XCURSOR_PATH=/home/$USER/.local/share/icons com.discordapp.Discord
flatpak override --env=XCURSOR_THEME=Adwaita-dark com.discordapp.Discord
Finally, run the flatpak to see the applied changes:
flatpak run com.discordapp.Discord
File Chooser or similar Dialogues not opening
File Chooser, App Chooser, Email, Print, or Notification dialogues (and more) are provided by an XDG Desktop Portal, as per Desktop Integration for Wayland.
Check also whether your
XDG_CURRENT_DESKTOP environment variable corresponds to the
UseIn attribute for your XDG Desktop Portal.
Flatpak's logic for this has been changed to mimic that of xdg-desktop-portal more closely and thus requires the environment variable to be set, otherwise matching interfaces will be ignored even if there is only one implementation.
For instance xdg-desktop-portal-gtk has its
UseIn defined in
XDG_CURRENT_DESKTOP environment variable should be set to
gnome if not automatically done so by your desktop environment (users without DE may need to set this in
~/.xinitrc or another appropriate location) for the GTK portal to be used as a file chooser (and similar).
- Docker — a container virtualization environment
- LXD — is a next generation system container manager.
- systemd/systemd-nspawn — a lightweight, loosely chroot-like, OS-level OCI container environment native to systemd.