Skip to content

Develop KDE Software

There are three options, depending on how the software is shipped on KDE Linux:

Build KDE software that’s shipped on the base image

This workflow is used for developing KDE software that’s shipped on the base system, or even Qt. A list of such software can be found here (note that “workspace” includes Plasma, KWin, and Plasma-aligned apps such as System Settings and Discover).

The best way to do this is by using systemd-sysext, which allows overlaying built-from-source content on top of /usr/ without impacting the base system.

Setup

Prepend ~/.local/bin to your $PATH (save it to your .bashrc and .zshrc files and apply it to the current session as well):

echo 'export PATH="$HOME/.local/bin:$PATH"' | tee --append ~/.{bash,zsh}rc
export PATH="$HOME/.local/bin:$PATH"

Run the setup script:

set-up-system-development

Use

In a nutshell, you’ll compile and install software using kde-builder, then refresh the systemd extension, and then finally restart any services that you changed (e.g. Plasma), or the entire system.

For example, to compile and test a change to plasma-pa, do the following:

kde-builder plasma-pa
sudo systemd-sysext refresh
systemctl restart --user plasma-plasmashell.service

If you replace a core system component and find that everything is crashing after the refresh is applied, try rebooting in order to fully reload the new dependency in all running software.

When you’re finished developing or testing the change, disable (“un-merge”) the system extension:

sudo systemd-sysext unmerge

When you’re done with your built-from-source software (e.g. because it was accepted as a patch and merged), delete the installed files:

rm -r ~/kde/usr/*
# When you’re prompted to delete the read-only extension-release.kde file, answer 'n'

Build KDE app with a Flatpak manifest

To develop or test changes to the app code itself, build the app using flatpak-builder, so that the result is functionally identical to the app’s nightly Flatpak build.

To develop or test changes to a KDE Framework or other library used by multiple apps, the only relatively painless approach at the moment is to use kde-builder to build them all. See Developing KDE software that’s shipped on the base image.

Setup

flatpak-builder will install flatpak packages from the remote flathub-apps-built-locally. This remote is the official Flathub store.

flatpak remote-add --user --if-not-exists flathub-apps-built-locally https://flathub.org/repo/flathub.flatpakrepo

Make changes to just the app

First check out the source code for the KDE app you’d like to build. For example, here with Filelight:

# Create folder to hold KDE source code. Skippable if it already exists
mkdir -p ~/kde/src/

# Go into that folder
cd ~/kde/src/

# Download source code for Filelight
git clone git@invent.kde.org:utilities/filelight.git

# Go into Filelight’s source code folder
cd ~/kde/src/filelight

# Build Filelight as a flatpak
flatpak-builder build --user --install-deps-from=flathub-apps-built-locally --force-clean --ccache --install .flatpak-manifest.json

flatpak-builder will create a flatpak repo and remote named filelight-origin and export the freshly built Filelight flatpak to this flatpak repo.

Now run it:

org.kde.filelight

For further information, see:

Build any KDE software, using KDE Builder in Distrobox

If you need to work on some KDE software not preinstalled on the base system (so dependencies are also not pre-installed) that also does not or cannot build as a Flatpak, you can build it with kde-builder in a Distrobox:

# As per https://develop.kde.org/docs/getting-started/building/containers-distrobox
distrobox create --image docker.io/archlinux --name kdebuildercontainer --home ~/kdebuildercontainer_home
distrobox enter kdebuildercontainer
sudo pacman -Syu
sudo pacman -S nano
echo 'export PATH="$HOME/.local/bin:$PATH"' | tee --append ~/.{bash,zsh}rc
exit
distrobox enter kdebuildercontainer

# Install kde-builder as usual. https://develop.kde.org/docs/getting-started/building/kde-builder-setup

Article contributed by under the CC-BY-4.0 license.