Flatpak – A New Framework for Desktop Applications on Linux

Few days ago, we have published an article about Ubuntu’s Snaps. For those who haven’t read it yet, check the following link.

Snaps are introduced by Canonical for Ubuntu operating system, and later it was adopted by other Linux distributions such as Arch, Gentoo, and Fedora etc. A snap is a single binary package bundled with all required libraries and dependencies, and you can install it on any Linux distribution, regardless of its version and architecture.

Similar to Snaps, there is another tool called Flatpak. As you may already know, packaging distributed applications for different Linux distributions are quite time consuming and difficult process. Each distributed application has different set of libraries and dependencies for various Linux distributions. But, Flatpak, a new framework for desktop applications that completely reduces this burden. Now, you can build a single Flatpak app and install it on various operating systems. How cool, isn’t it?

Also, the users don’t have to worry about the libraries and dependencies, everything is bundled within the app itself. Most importantly, Flaptpak apps are sandboxed and isolated from the rest of the host operating system, and other applications. Another notable feature is we can install multiple versions of the same application at the same time in the same system. For example, you can install VLC player version 2.1, 2.2, and 2.3 on the same system. So, the developers can test different versions of same application at a time.

Flatpak’s lead developer, Alexander Larsson, says about it:

“Application developers on Linux have always been prevented from having a direct relationship with their users. With Flatpak we’re aiming to change that, so developers know exactly what their users are getting. With this launch we are making that goal a reality.”

In this tutorial, we will see how to install Flatpak applications.

Install Flatpak

Flatpak is available in Arch Linux, Ubuntu, Debian, Fedora, and Mageia distributions.

To install Flatpak on Arch Linux, run:

sudo pacman -S flatpak
Install Flatpak in Arch

Install Flatpak in Arch

On Fedora 23 and later, Flatpak is available in the default repositories.

To install it, just run:

sudo dnf install flatpak

On Ubuntu, add the following repository and install Flatpak as shown below.

sudo add-apt-repository ppa:alexlarsson/flatpak
sudo apt update
sudo apt install flatpak

On Debain, add the following custom repository and install Flatpak as root user as shown below.

wget -O - https://sdk.gnome.org/apt/debian/conf/alexl.gpg.key|apt-key add -
echo "deb [arch=amd64] https://sdk.gnome.org/apt/debian/ jessie main" > /etc/apt/sources.list.d/flatpak.list
apt install apt-transport-https
apt update
apt install flatpak

To install Flatpak on Mageia, run:

sudo urpmi flatpak

Usage

Many popular applications are available as flatpaks.

Stable GNOME applications:

  • Builder
  • Calculator
  • Calendar
  • Characters
  • Clocks
  • Dictionary
  • Evince
  • Eye of Gnome
  • Gedit
  • Iagno
  • Maps
  • Notes (Bijiben)
  • Polari
  • Rhythmbox
  • Todo
  • Weather
  • Web (Epiphany)

To install these stable Flatpaks, we need to add the gnome-apps repository.

To do so, run:

wget https://sdk.gnome.org/keys/gnome-sdk.gpg
flatpak remote-add --gpg-import=gnome-sdk.gpg gnome-apps https://sdk.gnome.org/repo-apps/
Deepin Terminal_016

Add the gnome-apps repository

After adding the repository, list the available apps using command:

flatpak remote-ls gnome-apps --app

Sample output:

org.gnome.Builder
org.gnome.Calculator
org.gnome.Calendar
org.gnome.Characters
org.gnome.Dictionary
org.gnome.Epiphany
org.gnome.Evince
org.gnome.Maps
org.gnome.Polari
org.gnome.Rhythmbox3
org.gnome.Todo
org.gnome.Weather
org.gnome.bijiben
org.gnome.clocks
org.gnome.eog
org.gnome.gedit
org.gnome.iagno

Deepin Terminal_017

All the apps in the repository use the version name of “stable”.

Applications in this repository require the 3.20 version of the org.gnome.Platform runtime.

To install the stable runtimes, run:

flatpak remote-add --gpg-import=gnome-sdk.gpg gnome https://sdk.gnome.org/repo/

Now, let us install a flatpak app.

To install any Stable GNOME applications, for example Evince, run:

flatpak install gnome-apps org.gnome.Evince stable

Sample output:

1 delta parts, 2 loose fetched; 4359 KiB transferred in 31 seconds

Deepin Terminal_018

After installing

Nightly GNOME applications:

Here is the list of GNOME nightly applications:

  • Builder
  • Calculator
  • Calendar
  • Characters
  • Clocks
  • Dictionary
  • Documents
  • Evince
  • Eye of Gnome
  • Games
  • Gedit
  • Gitg
  • Glade
  • Iagno
  • Maps
  • News
  • Notes (Bijiben)
  • Polari
  • Rhythmbox
  • Todo
  • Videos (Totem)
  • Web (Epiphany)
  • Weather

To add the GNOME nightly apps repository, run:

wget https://sdk.gnome.org/nightly/keys/nightly.gpg
flatpak remote-add --gpg-import=nightly.gpg gnome-nightly-apps https://sdk.gnome.org/nightly/repo-apps/

To list the available apps in the NIGHTLY repository, run:

flatpak remote-ls gnome-nightly-apps --app

All the apps in the repository use the version name of “master”. Applications in this repository require the nightly version of the org.gnome.Platform runtime.

To install the nightly runtimes, run:

flatpak remote-add --gpg-import=nightly.gpg gnome-nightly https://sdk.gnome.org/nightly/repo/

For example, to install gedit run:

flatpak install gnome-nightly-apps org.gnome.gedit master

And to update it, run:

flatpak update org.gnome.gedit master

Conclusion

Like Ubuntu snaps, Flatpak is also in early development stage. You might be encountered with some errors while testing flatpak apps. As of now, the flatpak apps can be installed only via command line, however in near future flatpak will be integrated with GNOME software, and can be installed graphically.

That’s all for now. Hope you had basic idea about Flatpak.

If you find this guide useful, please share it on your social networks and support OSTechNix.

Cheers!

Reference links: