Install Flatpak Applications on your RPi - sakaki-/gentoo-on-rpi-64bit GitHub Wiki

Install standalone, pre-compiled Flatpak apps on your Gentoo RPi4 (or RPi3)!

Introduction

Flatpak is a packaging technology for Linux, that allows apps (along with their dependencies) to be deployed in a distro-independent binary form.

Users do not need root privileges to install or run such apps; both they, and their bundled libraries etc. are isolated from potentially conflicting versions on the 'host' OS. Furthermore, when such apps are run, the Flatpak infrastructure provides a degree of user-configurable sandboxing, for security.

A wide variety of Flatpak-packaged apps are available via the Flathub repo, many of which are compiled for aarch64 or arm (and so may be run, in principle, on the RPi4B and RPi3B/B+).

In this brief tutorial, we'll run through how to set up Flatpak on your 64-bit Gentoo RPi4 (or RPi3), and also how to start downloading and using precompiled apps from Flathub. It's a relatively quick and simple process, that opens up a wide variety of new software to try!

Prerequisites

You'll need a RPi4 B (or RPi3 B/B+) running the most recent 'full' copy of the gentoo-on-rpi-64bit image. I'm going to assume you have performed a first boot, have been able to log in as root (initial password raspberrypi64), and that you have network connectivity (ping etc. works).

Ensuring your Image is Up-to-Date

Although optional, it is wise to ensure your image is fully up-to-date before proceeding further.

To do so, issue:

demouser@pi64 ~ $ sudo genup

Let this process run to completion - it may take a few hours if a lot has changed. Once you see the message:

* All done - your system is now up to date!

you can safely continue.

Setting up the Overlay

At the time of writing, Gentoo does not have Flatpak in its main tree, so we need to leverage an appropriate overlay (user ebuild repository) from GitHub (here). Issue:

demouser@pi64 ~ $ sudo nano -w /etc/portage/repos.conf/flatpak-overlay.conf

and place the following text in that file:

[flatpak-overlay]
priority = 50
location = /usr/local/portage/flatpak-overlay
sync-type = git
sync-uri = https://github.com/fosero/flatpak-overlay.git
auto-sync = Yes

Save, and exit nano.

Now we have its metadata set up, we can pull in a copy of the overlay itself. Issue:

demouser@pi64 ~ $ sudo emaint sync --repo flatpak-overlay

Next, we need to allow Portage to build the various packages contained in flatpak-overlay, since they are not (at the time of writing) keyworded for aarch64. Issue:

demouser@pi64 ~ $ sudo nano -w /etc/portage/package.accept_keywords/flatpak

and place in that file:

sys-apps/flatpak * ~*
# dependencies of flatpak
acct-group/flatpak * ~*
acct-user/flatpak * ~*
dev-util/flatpak-builder * ~*
sys-apps/xdg-desktop-portal-gtk	* ~*
sys-fs/libostree * ~*

Save, and exit nano.

The above simply says, to allow as a build candidate on the local machine those versions of each package (e.g. sys-apps/flatpak) which have been marked as stable for any architecture (the *) or as testing on any architecture (the ~*).

Finally, bring your eix index up-to-date to include the new packages (this step is optional):

demouser@pi64 ~ $ sudo eix-sync -0

(that's a zero). This does not hit the network.

Installing Flatpak

With that done, we can proceed to emerge Flatpak and its dependencies. Since (at the time of writing) these packages are not yet on the binhost, this will involve a fair-sized local compile. As such, it makes sense to maximize your system's parallel compilation ability.

By default, the Gentoo image ships with a very conservative (single-threaded) build setting. If you are using a 2GiB or 4GiB RPi4, you can safely increase this. To do so, issue:

demouser@pi64 ~ $ sudo nano -w /etc/portage/make.conf

and uncomment the MAKEOPTS and EMERGE_DEFAULT_OPTS lines, so the full enclosing stanza now reads:

# override default build parallelism by uncommenting the following
# two lines, and modifying the values as required
# Pi4 users (particularly those with a 4GiB variant) can afford to be
# more aggressive here
MAKEOPTS="-j5 -l4"
EMERGE_DEFAULT_OPTS="--jobs=5 --load-average=4"
# caution! many parallel threads and / or emerge jobs may cause your
# RPi3/4 to run out of memory during large builds, or genup runs

Leave the rest of the file as-is. Save, and exit nano.

NB: users on 1GiB RPi 3B/B+ or 1GiB RPi 4B systems should stick with the default MAKEOPTS and EMERGE_DEFAULT_OPTS settings, and not make the above change.

Now install flatpak:

demouser@pi64 ~ $ sudo emerge -v sys-apps/flatpak

Let the build run to completion (it will take some time).

Setting up the Flathub Remote Source

Now we can set up the Flathub repository (remote source), from which apps can be downloaded. To do so, issue:

demouser@pi64 ~ $ flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

Note that you don't need sudo to do this.

Once it completes, reboot your RPi to ensure all necessary services etc. are running correctly.

Install Flatpak Apps from Flathub

Now everything is in place, you can download and run apps from Flathub!

To get a list of all compatible applications (aarch64 and arm - both 64-bit and 32-bit apps can be used), issue:

demouser@pi64 ~ $ flatpak remote-ls

You can also web-browse through a list of Flathub apps here.

Please bear in mind however, that some of the apps shown on that website may only be available in a binary format incompatible with the RPi, such as x86_64; this issue does not occur when using remote-ls (which filters by default).

So, let's say as an example that you wanted to install the Midori web browser. To do so, issue e.g.:

demouser@pi64 ~ $ flatpak install midori

You'll then be asked to check the repo to use, the fully qualified name for the app, and then whether you wish to install it (and its runtime deps). Consider what you are being asked and, if it seems sensible, press y and Enter each time to proceed.

The desired app, and its dependencies, should then commence downloading:

Installing a Flatpak application on 64-bit Gentoo

NB: the first time you install e.g. a GNOME app, Freedesktop app etc., it will generally pull down and install one or more large 'platform' packages. However, subsequent installations of apps on the same platform will (in general) be able to reuse this, so will download more quickly.

Running Flatpak Apps

Once installed, Flatpak apps (if they have a GUI, which most do) automatically get a menu item installed in the host desktop. To run the app, simply click on this as you normally would:

Running a Flatpak application (Midori) on 64-bit Gentoo

There may be a short delay (up to 20 seconds or so) while the application loads and starts up.

Have fun!

Notes and Limitations

Please note that this is not a Flatpak tutorial; there's a lot more you can do with this tool. For example, you can easily package your own Flatpak apps, restrict the permissions of running apps, uninstall existing apps etc. Please see the Flatpak website for further details.

Also note that the performance of applications requiring e.g. graphical acceleration may be disappointing, depending on the versions of programs like mesa provided in the bundled runtimes.

Finally, please be aware that while most apps are benign, and the Flatpak sandboxing does afford some (customizable) protection, you should be aware of the security concerns that exist around this technology.

⚠️ **GitHub.com Fallback** ⚠️