KDE Development with Podman
Tags: podman, kde, linux
Published: 2021-08-10 12:04:18

## Introduction
I have been using KDE for quite some time and recently decided to start contributing to KDE development. However, I hit a few problems in the way before deciding to create a CLI tool.

## Toolbox
I use Fedora as my daily driver. [Toolbox](https://github.com/containers/toolbox) is built on top of [Podman](https://podman.io/). It is mainly designed for use with immutable OS like Fedora Silverblue but can be used with other distributions. I use toolbox for most of my development, so I started setting up the development environment in it as outlined [here](https://community.kde.org/Get_Involved/development).

However, when I tried building [Solid](https://community.kde.org/Solid) using kdesrc-build, I started getting many errors about Undefined Reference everywhere. I tried installing pretty much the whole plasma inside the toolbox but couldn't fix the problem. I also opened a bug report but no luck. So I kind of left there to get some fresh air.

## Docker
This was my second attempt to set up a development environment. KDE provides a guide to set up a docker container for development [here](https://community.kde.org/KDE_PIM/Docker). 

It seemed a little old since it used nvidia-docker instead of [nvidia-container-toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html). There were a few problems though:
1. Docker didn't work well when I installed it.
2. Neither nvidia-docker nor nvidia-container-toolkit are not officially supported in Fedora

I didn't try too hard to fix docker in my system since I use Fedora Silverblue on my laptop, and I don't want to install docker on it. So I moved on to podman.

## Podman
At first, I thought I could just modify the build scripts a little to work with [Podman](https://podman.io/). I was partially correct since to get the container started, I just replaced the docker command with podman.

However, getting Nvidia to work was much more complicated. Now, I am not a container expert, so a lot of it was because of my unfamiliarity with the technology. At first, I had to get nvidia-container-toolkit using CentOS package. The test containers given in the instructions [here](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html) worked fine. However, I soon understood that nvidia-container-toolkit requires basing the image on nvidia official containers or going through [this](https://gitlab.com/nvidia/container-images/cuda/-/tree/master/) and figure out how to create a custom container. Most documentation online seemed to be about nvidia-docker or just covered the install portion of nvidia-container-toolkit. There was almost nothing available on how to create a custom image. After some digging around and copying and pasting (I still don't understand some of it), I was able to create a container with nvidia-smi, and other cuda commands working. 

At this point, the modification to the collection of scripts was getting a little bigger. So I decided to create a CLI tool to combine everything.

## [KDE Container CLI](https://github.com/Ayush1325/kde-container-cli)
I started writing a cli that could create containers for me and added features like launching GUI apps inside the container without entering. It supports both podman and docker, but the docker side isn't tested since I don't use docker much.

### Usage
It uses a structure of subcommands to work. We have four commands at the top level:
1. **Build:** To build the container image for development.
2. **Run:** To run/start/attach to the container.
3. **Config:** For storing extra configuration that might be required in some systems. E.g., Podman requires adding to xhost to display GUI applications.
4. **Launch:** To launch GUI applications like Kdevelop without entering the container.

All commands other than Config have a subcommand to choose between docker and podman. 

### Problems
1. Nvidia still doesn't work perfectly. GUI applications like glxgear and qtcreator can't seem to find graphic drivers even though CLI applications work.
2. Docker part isn't tested.

## Conclusion
My current setup for KDE development is working quite well. The CLI tool is hosted [here](https://github.com/Ayush1325/kde-container-cli). I hope to finally start some work with KDE development now that everything seems to be working.

Contributions are, of course, welcome from everyone in the form of issues or code. It would be great if someone could fix the nvidia part of the CLI.

Currently, the binary is distributed as a tar.gz file with the dockerfiles and other assets required.