Building your first Flatpak

This tutorial provides a quick introduction to building Flatpaks. In it, you will learn how to create a basic Flatpak application, which can be installed and run.

The Setup page should be followed before doing this tutorial.

1. Install a runtime and the matching SDK

Flatpak requires every app to specify a runtime that it uses for its basic dependencies. Each runtime has a matching SDK (Software Development Kit), which contains all the things that are in the runtime, plus headers and development tools. This SDK is required to build apps for the runtime.

In this tutorial we will use the Freedesktop 1.6 runtime and SDK. To install these, run:

$ flatpak install flathub org.freedesktop.Platform//1.6 org.freedesktop.Sdk//1.6

2. Create the app

The app that is going to be created for this tutorial is a simple script. To create it, copy the following:

echo "Hello world, from a sandbox"

Now paste this into an empty file and save it as

3. Add a manifest

Each Flatpak is built using a manifest file which provides basic information about the application and instructions for how it is to be built. To add a manifest to the hello world app, add the following to an empty file:

    "app-id": "org.flatpak.Hello",
    "runtime": "org.freedesktop.Platform",
    "runtime-version": "1.6",
    "sdk": "org.freedesktop.Sdk",
    "command": "",
    "modules": [
            "name": "hello",
            "buildsystem": "simple",
            "build-commands": [
                "install -D /app/bin/"
            "sources": [
                    "type": "file",
                    "path": ""

Now save the file alongside and call it org.flatpak.Hello.json.

In a more complex application, the manifest would list multiple modules. The last one would typically be the application itself, and the earlier ones would be dependencies that are bundled with the app because they are not part of the runtime.

4. Build the application

Now that the app has a manifest, flatpak-builder can be used to build it. This is done by specifying the manifest file and a target directory:

$ flatpak-builder app-dir org.flatpak.Hello.json

This command will build each module that is listed in the manifest and install it to the /app subdirectory, inside the app-dir directory.

5. Test the build

To verify that the build was successful, run the following:

$ flatpak-builder --run app-dir org.flatpak.Hello.json

Congratulations, you’ve made an app!

6. Put the app in a repository

Before you can install and run the app, it first needs to be put in a repository. This is done by passing the –repo argument to flatpak-builder:

$ flatpak-builder --repo=repo --force-clean app-dir org.flatpak.Hello.json

This does the build again, and at the end exports the result to a local directory called repo. Note that flatpak-builder keeps a cache of previous builds in the .flatpak-builder subdirectory, so doing a second build like this is very fast.

This second time we passed in –force-clean, which means that the previously created app-dir directory was deleted before the new build was started.

7. Install the app

Now we’re ready to add the repository that was just created and install the app. This is done with two commands:

$ flatpak --user remote-add --no-gpg-verify tutorial-repo repo
$ flatpak --user install tutorial-repo org.flatpak.Hello

The first command adds the repository that was created in the previous step. The second command installs the app from the repository.

Both these commands use the –user argument, which means that the repository and the app are added per-user rather than system-wide. This is useful for testing.

Note that the repository was added with –no-gpg-verify, since a GPG key wasn’t specified when the app was built. This is fine for testing, but for official repositories you should sign them with a private GPG key.

8. Run the app

All that’s left is to try the app. This can be done with the following command:

$ flatpak run org.flatpak.Hello

This runs the app, so that it prints Hello world, from a sandbox.