Spotlight - Flatpak and Flathub

You may have heard of Flatpaks, maybe even Flathub? The Flatpak community tries to provide a general package format and marketplace / app store for GNU/Linux packages. Since I am using Flatpak for quite some time now, I wanted to share some experience and details about it.

Spotlight - Flatpak and Flathub

You may have heard of Flatpaks, maybe even Flathub? The Flatpak community tries to provide a general package format and marketplace / app store for GNU/Linux packages. Since I am using Flatpak for quite some time now, I wanted to share some experience and details about it.

Another package manager?

Before going into the details, you may ask: "Do we need another package format/manager?" or "What about deb or rpm?" and "I have XXX, and it works fine, why switch?"

It is not just some random team, that works on the idea, but flatpak is the successor of xdg-app, which is developed under the umbrella of freedesktop.org. Specifications and concepts are matching up with other Desktop Projects like GNOME or KDE. You can find Wayland, upower and many other projects hosted and maintained via freedesktop.org.

To clarify this. Flatpaks are not "just another package format". Flatpak is the idea of having a single package format for all GNU/Linux distributions across multiple architectures in an Open Source marketplace. This is comparable to the effort made with Wayland.

Flathub

Apropos marketplace: There is a fully open source marketplace application to host Flatpaks. The most popular instance of this software is flathub.org. You can find all kind of software here. Many large software projects are offering a Flatpak for installation. If not, the chance is high, that the community has taken care of this.

If you need Steam or Minecraft for some gaming, LibreOffice or GIMP for productive work or Slack and Polari for chats, you will most likely find it at Flathub. There are also lots of utilities to manage passwords or update your firmware via fwupd.

Screenshot - flathub.org

There is also a very handy guide for many distributions. In case you wonder, how to get started - You are just some commands away.

Screenshot - flathub.org

Let's have a more detailed look at Flatpaks, if you want.

Flatpaks

Flatpak is a new package format, specifically designed for Desktop Applications. But it is more - You can think of a designed idea of distribution independent build and publishing formats. Sounds weird how? I will dig into this in the following sections. Additionally, let's have a look at some statements, you can find on the web:

  • Flatpaks are huge
  • You will install all dependencies per package
  • The sandbox does not allow me to use XXX

There is some truth to these, that will be clarified in the coming sections, too.

Features

First, let's have a look at the features. Shall we?

For every distribution

As long as you have flatpak installed on your distribution, you can immediately start to build and use Flatpak applications. This allows you to use exactly the same application with exactly the same version on multiple Linux distributions.

If you want to know how you can install Flatpak on your distribution, just check out the list of supported OS. You can find basically every major distribution like Ubuntu, Fedora, Arch Linux or even Chrome OS.

Batteries included

Since Flatpaks are built with a dedicated and versioned runtime, you can expect no major changes in these runtimes. Each and every application can pull in the runtime (including libraries and dependencies) that it needs. This means, that a distribution update can not break your application or the other way.

The runtimes are also pre-built and versioned on their own. I will explain the different layers of runtimes, applications and extensions in the Architecture section.

For developers

From a developer perspective, you will have all the things you often desired. Using the "latest" package of something or "LTS" shouldn't be the matter of the target distribution, but your personal workflow.

Furthermore, it is hard to package software for a multitude of distributions and maintain these properly. Getting used to DEB, RPM and all the different hurdles isn't necessary. Instead, you are granted with a complete build and delivery framework, that enables you to publish your application on Flathub or on your own Flatpak repository.

There are also developers documentations ready.

Basic Concepts

Now that the Features are out of the way, we should have a look at the architectural things. There are two major aspects, I want to talk about.

Applications, Runtimes, Bundled libraries

The first part should address the "size" issue of Flatpak. You can often hear things like "You will install another GNOME, just to run the application." This is not entirely true, but looks more like this:

© 2021, Daniel Schier, CC BY-SA 4.0

So yes, it is possible to package all dependencies in the Flatpak Application itself. But, this is not needed. Instead, you can use runtimes, that provide libraries for you. These will be installed once and can be used by all Flatpak applications afterwards.

On the other hand, Flatpaks can use different versions of a runtime and request these during the installation. Bundling a library is only needed, if you use something that is not already provided in a runtime package.

And all of this is fully independent of the libraries of your operating system. It does not matter, if your operating system is running an older version of GNOME or KDE, you can use the newest GNOME applications from flathub or any other published software. There is also no need to re-package with different libraries.

Issues

Flatpak is not issue free. Most of these issues come through the sandboxing of Flatpaks. A Flatpak does not have access to your operating system or tools that are installed on it. For many applications, that is basically no issue.

But there are some apps that are deeply integrated. An IDE for example wants to use all kind of linters, runtimes, engines, etc., which are not provided in the Flatpak itself. But shipping all possible plugins with the IDE is also a bad idea. There are some ways to work around this, and the community is working towards a proper way to provide extensions and portals for more scenarios.

Screenshot - GNOME Software

Nevertheless, this leads to some issues with virtualization, IDE integrations or even status notifications in the Nextcloud client.

Using Flatpaks

Flatpak (the package needed to use Flatpaks) can be installed on many Linux distributions. Fedora (my preferred distribution) ships Flatpak on all desktop variants per default. On Ubuntu, OpenSUSE or Arch Linux, you may need to install the packages beforehand. You can find the guides for your distribution in the documentation.

Afterwards, you can enable Flathub, for example. This is pretty easy and boils down to a single command.

# Enable flathub.org system wide
$ flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

You can list the installed repositories, too.

# List enabled repositories
$ flatpak remote-list 
Name    Options
flathub system

Afterwards, you can search and install programs. Let's do this with the application I am maintaining on Flathub - Shattered Pixel Dungeon.

# Search for a package
$ flatpak search shattered
Name                                  Description                                                                                Application ID                                         Version               Branch              Remotes
Shattered Pixel Dungeon               Roguelike RPG, with pixel art graphics and lots of variety and replayability               com.shatteredpixel.shatteredpixeldungeon               1.1.1                 stable              flathub

# Install the package
$ flatpak install com.shatteredpixel.shatteredpixeldungeon
Looking for matches…

com.shatteredpixel.shatteredpixeldungeon permissions:
    ipc   network   pulseaudio   wayland   x11  dri



        ID                                                  Branch            Op            Remote             Download
 1. [✓] com.shatteredpixel.shatteredpixeldungeon            stable            i             flathub            83,5 MB / 83,9 MB

Installation complete.

This will create a desktop icon to start the application, but you can also run it from the command line. Since the runtimes are already installed, the package is quite small.

# Start via command line
$ flatpak run com.shatteredpixel.shatteredpixeldungeon

And the result is the game.

Screenshot - Shattered Pixel Dungeon

You can also uninstall the game, after you completed it. ;)

# Uninstall a flatpak
$ flatpak uninstall com.shatteredpixel.shatteredpixeldungeon

And if you want to make some housekeeping occasionally, there are options, too.

# Cleanup unused packages
$ flatpak uninstall --unused

# Update packages
$ flatpak update

You can find the complete command reference in the Flatpak documentation.

If you are interested to dig a bit deeper, I want to provide some links.

Flathub—An app store and build service for Linux
Find and install hundreds of apps and games for Linux. Enjoy GIMP, GNU Octave, Spotify, Steam and many more!
Flatpak—the future of application distribution
The days of chasing multiple Linux distributions are over. Standalone apps for Linux are here!
Flatpak Command Reference — Flatpak documentation
Getting Started with Flatpak - Fedora Magazine
Fedora is a distribution that does not shy away from emerging technology (after all, one of its founding principles is First). So it comes as no surprise that Fedora is on the leading edge of a revolutionary new software package system. This is not the first time Flatpak has been mentioned on the Ma…
An introduction to Fedora Flatpaks - Fedora Magazine
This article explains the motivation behind Fedora Flatpaks, how to add the remote, how to use it and where to find resources.

Snaps and AppImages

I know, I know. If you say Flatpak, you should also say Snap and AppImage. I will come to these in a future article.

For now, both are having different objectives and concepts than Flatpak, but both may be useful for one or the other.

Conclusion