KDE Linux/Develop KDE software
There are two primary approaches here: developing KDE software that's shipped on the base image, and developing KDE software that can be built using Flatpak.
KDE software that's shipped on the base image
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.
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.
In practice, this workflow should be used to develop all KDE software that's included with KDE Linux, except for a few apps that are shipped as Flatpaks, which can be found here. You can use this for KDE apps that get shipped as Flatpaks, but it's not recommended since the built app will offer a different UX due to no sandboxing.
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'
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.
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 [email protected]:utilities/filelight.git
# Or: git clone https://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 flatpak org.kde.filelight to this flatpak repo.
flatpak-builder will create a flatpak repo and remote named "debug-origin" and export the freshly built flatpak org.kde.filelight.Debug (containing debug symbols) to this flatpak repo.
Then, flatpak-builder will install the flatpak org.kde.filelight from the flatpak remote "filelight-origin".
Now run it:
org.kde.filelight
For further information, see:
- https://docs.flatpak.org/en/latest/getting-started.html
- https://develop.kde.org/docs/packaging/flatpak/packaging/
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
