Nova Flow OS
KDE Developer Platform
KDE Developer Platform
  • KDE Developer Platform
    • Getting started
      • Building KDE software
        • KDE software
        • Where to find the development team
        • Learning more
        • Choose what to work on
        • Source code cross-referencing
        • Installing build dependencies
        • Set up a development environment
        • Building KDE software with kdesrc-build
        • Basic troubleshooting
        • Tips and tricks
        • IDE Configuration
          • Setting up an IDE for KDE development
          • Visual Studio Code
          • Qt Creator
          • Kate
          • KDevelop
          • CLion
          • Sublime Text
        • Building KDE software manually
        • Building KDE software with distrobox and podman
      • Kirigami
        • KDE is ours
        • Setting up and getting started
        • Explaining pages
        • Layouts, ListViews, and Cards
        • Adding actions
        • Adding a dialog
        • Using separate files
        • Next steps
        • Colors and themes in Kirigami
        • Typography
        • Actions based components
        • Page rows and page stacks
        • Scrollable pages and list views
        • Cards
        • Drawers
        • Chips
        • Dialog types
        • Controls and interactive elements
        • Form layouts
        • Inline messages
        • Action toolbars
        • Progress bars and indicators
        • List views
        • Understanding CMakeLists
        • Figuring out main.cpp
        • Connect logic to your QML user interface
        • Connect models to your QML user interface
        • About page
        • Introduction to Kirigami Addons
        • FormCard About pages
        • Form delegates in your settings pages
      • KXmlGui
        • Getting started with KXmlGui
        • Hello World!
        • Creating the main window
        • Using actions
        • Saving and loading
        • Command line interface
      • Python with Kirigami
        • Apps with QML and Python
        • Your first Python + Kirigami application
        • Creating a Python package
        • Creating a Flatpak
      • Common programming mistakes
      • Adding a new KDE project
    • Features
      • Icons
      • Configuration
        • The KConfig Framework
        • Introduction to KConfig
        • Using KConfig XT
        • KDE Frameworks 6 porting guide
        • Settings module (KCM) development
        • KConfigDialog
      • D-Bus
        • What is D-Bus practically useful for?
        • Introduction to D-Bus
        • Accessing D-Bus interfaces
        • Intermediate D-Bus
        • Creating D-Bus interfaces
        • Using custom types with D-Bus
        • D-Bus autostart services
      • Create your own mouse cursor theme
      • Session management
      • Archives
      • Desktop file
      • KAuth
        • Privilege Escalation
        • Using actions in your applications
      • KIdleTime
      • Akonadi: personal information management
        • Debugging Akonadi Resources
        • Using Akonadi in applications
      • Concurrent programming
      • Solid
      • Sonnet
    • Plasma themes and plugins
      • Getting started
      • Plasma Widget tutorial
        • How to create a plasmoid
        • Setup
        • Porting Plasmoids to KF6
        • Testing
        • QML
        • Plasma's QML API
        • Widget Properties
        • Configuration
        • Translations / i18n
        • Examples
        • C++ API
      • KWin Effects
      • Plasma Desktop scripting
        • Javascript Interaction With Plasma Shells
        • Templates
        • Examples
        • API documentation
        • Configuration keys
      • Plasma Style tutorial
        • Creating a Plasma Style quickstart
        • Understanding Plasma Styles
        • SVG elements and Inkscape
        • Background SVG format
        • System and accent colors
        • Theme elements reference
        • Porting themes to Plasma 5
        • Porting themes to Plasma 6
      • Aurorae window decorations
      • KWin scripting tutorial
        • Quick start
        • KWin scripting API
      • Wallpapers
      • Plasma comic
        • Tutorial
        • Testing and debugging
        • Examples
      • Create a custom Window Switcher
      • KRunner C++ Plugin
        • Basic Anatomy of a Runner
        • KRunner metadata format
    • Applications
      • Creating sensor faces
      • Dolphin
        • Creating Dolphin service menus
      • Kate
        • Kate plugin tutorial
      • KMines
        • Making a KMines theme
      • Writing tests
        • Appium automation testing
    • Packaging
      • Android
        • KDE on Android
        • Building applications for Android
        • Packaging and publishing applications for Android
        • Publishing on Google Play
          • Introduction
          • Packaging your app
          • Adding your app to Google Play
          • Publishing your app
          • Releasing new versions of old apps
        • Porting applications to Android
          • Basic porting
          • Making applications run well on Android
          • Metadata
      • Windows
        • Packaging and publishing applications for Windows
        • Publish your app in the Microsoft Store
          • Packaging your app for the Microsoft Store
          • Submitting your app to the Microsoft Store
      • Plasma Mobile
        • KDE on mobile devices
        • Porting a new device to Plasma Mobile
        • KDE Telephony stack
          • General Overview
          • Kernel layer
          • System daemons
            • General overview
            • Developing Telephony functionality
            • ModemManager Telephony functions
          • Session daemons
          • QML declarative plugin layer
          • KDE application layer
        • Execute applications
      • Distributing KDE software as Flatpak
        • Your first Flatpak
        • Extending your package
        • Nightly Flatpaks and Flathub
        • Testing your Flatpak
    • System administration
      • Shell scripting with KDE dialogs
      • Kiosk: Simple configuration management for large deployment
        • Abstract
        • Introduction to Kiosk
        • Kiosk keys
    • Contribute to the documentation
    • About
      • Readme
      • License
        • Creative Commons Attribution-ShareAlike 4.0 International
        • GNU General Public License 3.0 or later
Powered by GitBook
On this page
  1. KDE Developer Platform
  2. Packaging
  3. Distributing KDE software as Flatpak

Extending your package

Understand the core components of your manifest.

Let's first take a look at our previous manifest to understand what each thing does.

{
   "command": "kate",
   "desktop-file-name-suffix": " (Nightly)",
   "finish-args": [
      "--share=ipc",
      "--socket=fallback-x11",
      "--socket=wayland"
   ],
   "id": "org.kde.kate",
   "modules": [
      {
         "buildsystem": "cmake-ninja",
         "name": "konsole",
         "sources": [
            {
               "type": "git",
               "url": "https://invent.kde.org/utilities/konsole.git"
            }
         ]
      },
      {
         "buildsystem": "cmake-ninja",
         "name": "kate",
         "sources": [
            {
               "type": "git",
               "url": "https://invent.kde.org/utilities/kate.git"
            }
         ]
      }
   ],
   "runtime": "org.kde.Platform",
   "runtime-version": "5.15-21.08",
   "sdk": "org.kde.Sdk"
}
id: org.kde.kate
runtime: org.kde.Platform
runtime-version: "5.15-21.08"
sdk: org.kde.Sdk
command: kate
desktop-file-name-suffix: " (Nightly)"
finish-args:
  - "--share=ipc"
  - "--socket=fallback-x11"
  - "--socket=wayland"
modules:
  - name: konsole
    buildsystem: cmake-ninja
    sources:
    - type: git
      url: https://invent.kde.org/utilities/konsole.git
  - name: kate
    buildsystem: cmake-ninja
    sources:
      - type: git
        url: https://invent.kde.org/utilities/kate.git

While non-KDE software typically gets included to Flathub as YAML, KDE software added to the kdeapps and Flathub repositories is included via JSON manifests, so we will focus on that. The practical distinction between the above types for when writing a JSON manifest is mostly syntactic. For basic types like string, boolean, integer and object, their syntax in JSON would be simply:

"Property": "Value"

For array of strings, this would be:

"Property": [ "String1", "String2", "String3" ]

wherein [] represents an array.

For array of objects and strings, this would be something like:

"Property": ["string1", {"PropertyA": "ValueA", "PropertyB": "ValueB"}]

wherein inside the [] array, there is a string and an object, the latter being everything inside {}.

You must be wary of the correct syntax for each type of property, as this can get confusing pretty fast, especially if you are not well acquainted with JSON syntax.

Now let's take a look at each component from a logical sequence of information (rather than the arbitrary one in the example).

id refers to the name of the flatpak package, the one that will be used for searching or installing. So when you run flatpak install kate, you can find org.kde.kate because flatpak is performing a fuzzy search based on the id.

command refers to the default program to be executed when you run a flatpak, in this case kate. So when you run flatpak run org.kde.kate you are effectively running kate from within the flatpak.

desktop-file-name-suffix is an addition to the package name as it will be shown in your application menu. In this case, Kate (Nightly).

runtime refers to the bundle of libraries used to ship with your application, as opposed to using your system libraries. Runtimes are the reason flatpak can run on any Linux distribution: you always ensure that your application runs against the same libraries. runtime-version simply determines to which version of those libraries your application will be built. Each application is built only once for each runtime version, and updating library versions is as simple as bumping one number up.

sdk refers to the bundle of development libraries used for building your application. Away from your sight, flatpak-builder creates a .build folder in the same place where your manifest is, builds it there, then creates a package. Here we use the KDE/Qt development libraries provided by org.kde.Sdk.

finish-args are the arguments pertaining to the permissions your flatpak will have. --share=ipc provides access to shared memory, --socket=wayland allows your application to be controlled by a Wayland compositor, like KWin, and --socket=fallback-x11 allows your application to be controlled by an X server, usually Xorg, but only when using an X11 session, meaning that the app won't have unnecessary X11 permissions while on a Wayland session.

modules are the things to be compiled and their respective compilation options. Here we build Konsole so we can make use of its KonsoleParts for Kate to display its embedded terminal. The name property is used for clarification and in the case of multiple flatpak manifests. buildsystem is the software used to compile, which in KDE software's case is usually cmake or cmake-ninja.

Like the above tag example, there are other properties that can be used to improve your flatpak package.

One of the top level properties that is common in the kdeapps repository is branch. It is not about git branches, but rather flatpak branches. Apps from flathub are usually of branch stable or of specific versions, those of kdeapps are usually master, and those of flathub-beta are usually beta. This way a user can install the same application under different branches as defined by the package publisher.

rename-icon allows you to specify an icon in your sources that will be renamed according to the id of the application so it gets properly detected by the .desktop file used for the flatpak in specific cases.

There are some particularly useful non-top-level properties.

builddir allows your build to use an out of source build folder in case you have any issues with the default build folder place.

cleanup allows you to delete specific files from your final flatpak. This way it is possible to make the resulting package smaller. In case you'd like to see the folder structure of the generated package so you are aware of which files were generated, you can get a shell inside a non-installed flatpak during build time using flatpak-builder --run <build-dir> <manifest> bash or get a shell in an installed flatpak while running using flatpak ps and then flatpak enter <instance> bash. After that, you can navigate to /app, which is where the actual flatpak files will be.

config-opts is used by buildsystems like cmake in case specific options or flags are needed to compile the application. This can be useful for example to toggle debug/testing mode, or to hinder the creation of docs.

base is used for cases where applications extend upon existing applications. For instance, org.kde.falkon extends upon io.qt.qtwebengine.BaseApp.

build-commands is used in case your build system is simple rather than cmake or cmake-ninja and you need to specify the compilation commands yourself.

PreviousYour first FlatpakNextNightly Flatpaks and Flathub

Last updated 9 months ago

If we read the , we can see values in parentheses for each property, namely string, boolean, integer, object, array of strings and array of objects and strings.

When building, the first step of flatpak-builder is to automatically fetch the source code (if it's not already present). The sources are used to specify where you want to fetch the source code from, but it is usually of type git or archive. Since the applications from our kdeapps repository are nightlies, those usually take a git type of source. Official releases either use archive by pulling from or git by specifying a tag.

official flatpak-builder documentation
download.kde.org