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
Run the setup script:
_kde-linux-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
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
First set up a local repository in your home folder to hold your built-from-source Flatpak apps:
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. Skippable if already done
git clone [email protected]: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
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"' >> ~/.zshrc
exit
distrobox enter kdebuildercontainer
# Install kde-builder as usual. https://develop.kde.org/docs/getting-started/building/kde-builder-setup
