Flatpak
Desktop installations of Alpine Linux on x86_64 and aarch64 architectures can access software applications that are not available in the Alpine repositories by configuring Flatpak and enabling the Flathub repository. This document explains the steps to configure and use Flatpak.
Background
You may have realized that not every application that is available for Linux is available from the Alpine Linux package repositories. This observation actually applies to every Linux distribution in existence. No distribution packages every possible piece of software, and some distributions only ship older versions of packages when they ship them at all.
Flatpak is an approach to software packaging for Linux that is independent of the underlying distribution. Flatpak provides a way for applications to be installed along with their own set of libraries in the form of runtimes, or collections of software required to support applications. Standard runtimes use the GNU C library (glibc), so Flatpak packages can be used for applications that do not run natively on musl (for example, Steam). Applications running from Flatpak packages are sandboxed using Bubblewrap, which uses Linux kernel features to isolate environments from the rest of the system.
Flatpak does have some downsides. First of all, the application sandboxing is not perfect and has some holes in it. These weaknesses can be especially concerning since some Flatpak maintainers do not always keep up with security updates. Runtimes can become end-of-life, and there is currently not a way to compel maintainers to update their packages. In addition, Flatpak packages consume a lot more space on persistent storage – and use more RAM – when compared to native Alpine Linux packages. This extra space and extra RAM are both consumed by the duplicate versions of libraries shipped by the runtimes.
The canonical source of Flatpak packages, at least for the x86_64 and aarch64 architectures, is Flathub. Flathub contains numerous applications, both open source and proprietary. Some applications are also “verified,” meaning that they are built with the permission of the upstream authors of the software. This verification does not currently imply that such applications are actually built by the software developers, however.
Installation
First, we need to install and configure the base Flatpak application, which is in the official Alpine Linux repositories. Open a Konsole window and run the following commands, substituting my username (mmurphy2) with your username:
doas apk add flatpak
doas adduser mmurphy2 flatpak
doas flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
To get Flatpak working reliably, it is best to reboot the system. From KDE Plasma, the cleanest way to reboot is to go to the start menu, pick Restart, and then confirm the reboot action.
Browsing Packages
There are two main ways to see what kind of software is available through Flathub. The first (and simplest) way is simply to visit the Flathub website and review the package offerings. Clicking on a package will show a description, some screenshots, and information about the permissions that the package requires. There is also an indication as to how safe the package is expected to be, along with its license (open source or proprietary). By scrolling down a bit more, the Available Architectures for the package are displayed. Intel/AMD systems using the x86_64 architecture are supported by most packages. Many (but not all) packages also support aarch64, which is the recommended architecture for installing Alpine Linux on a Raspberry Pi 5. Note that some older versions of the Raspberry Pi were 32-bit only, and it is also possible to install a 32-bit version of Linux (e.g. arm7h) on a Raspberry Pi 3 or higher. Flathub does not support these cases.
A second way to browse Flatpak packages on Flathub is to use KDE’s Discover application, which by default is available directly from the task bar using the 3rd icon from the left (the one shaped like a shopping bag). Discover will filter available applications based on the system’s architecture, which eliminates one step in the process. However, Discover can be slow and has a few bugs, so using it is a bit of a two-edged sword.
Installing a Flathub Package
Recall that the kde-applications-games package doesn’t actually install any games. What good is a desktop without Solitaire? Fortunately, we can install KDE’s KPatience solitaire game from Flathub using either Discover or the command line.
Using Discover
Use the search box in the upper left to search for KPatience. Click on the entry for it, then click “Install from Flathub” in the upper right corner of the window. A progress bar will appear in the lower left corner, but it may not update properly due to the general bug level of Discover. After some delay, the progress bar will disappear, and the button in the upper right corner will change to “Launch.” When this occurs, the program has been installed successfully.
Using the Command Line
You can install Flatpak packages from the command line instead of using Discover. I find the command line installation to be more efficient and less prone to issues. Note that you should not need to use the doas command, since you added your user account to the flatpak group. To install our Solitaire game, run:
flatpak install flathub org.kde.kpat
Just press Enter to answer the default Y to both prompts (both the runtime dependency and the full installation prompts). Unlike Discover, you will actually see the progress bar move when using the command line.
Now, how did I know to use org.kde.kpat as the name of the thing to install with the flatpak command? If you go to the Flathub page for KPatience and click the little down arrow next to the blue Install button, it will show you the entire command. The package name is also the last component of the URL if you look at your browser’s address bar.
Testing the Package
After you have finished installing KPatience, you can go to the start menu and find it under the Games category. It should run properly when started.
To play the same version of the Solitaire game you’re used to seeing on Windows, choose the Klondike game.