~ 4 min read

How to Setup Distrobox on the Steam Deck

Distrobox is a way of running different distributions of linux from the terminal within a container. So you can have multiple installs of say ubuntu or fedora sat on top of your existing Linux distro. What is particularly interesting is it’s possible to install on your Steam Deck too in order to have a full linux distribution. Upgrades of SteamOS will remove anything not in the user partition, so here you have more freedom to install within a container without this happening. The distro containers you create will be tightly integrated with the host, allowing sharing of the HOME directory of the user, storage, USB devices and even graphical apps.

This means we can setup the steam deck in a similar way that Windows Subsystem for Linux does for Windows with a tight integration for programming without a dual boot configuration. So it’s essentially a Linux Subsystem for Linux. Here I’m going to show you how set it up and use it.

If you want to see me going through this process, you can find a video of it on youtube

Installation

To install, as we only have access to the user partition on the deck - we need to install distrobox and its dependencies to a custom directory (~/.local). Run the following curl commands to install Distrobox and it’s dependency podman. I did this on a clean install of SteamOS and had to change my deck users password before I could run them.

curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/install | sh -s -- --prefix ~/.local
curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/extras/install-podman | sh -s -- --prefix ~/.local

Both binaries then need to be added to the path. Within .bashrc add this to the bottom:

export PATH=$PATH:$HOME/.local/bin
export PATH=$PATH:$HOME/.local/podman/bin

Using Distrobox

Distrobox pulls Docker images using podman. To create an ubuntu distro for example I used:

distrobox create -i ubuntu:22.10

And then to start and use that container:

distrobox enter ubuntu-22-10

You should notice the prompt change to signify you’re now using Distrobox. If you then cat the release file you should see you’re now using ubuntu, but able to interact with the local filesystem.

cat /etc/*-release

Graphical Applications

It’s also possible to run graphical applications from within Distrobox containers. To do so you need to add the following xhost command to the bottom of ~/.bashrc.

xhost +SI:localuser:$USER

You should then find if you install and launch an app that uses a UI when using your Distrobox, it works as expected. I installed meld, a diffing tool for linux.

sudo apt-get install meld

Pyenv

One of the problems I originally hit on my coding on the deck video was pyenv wouldn’t install as I couldn’t install any of the build dependencies. This isn’t a problem with Distrobox since I can install all the build dependencies required in the container and then install pyenv.

sudo apt update; 
sudo apt install make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
sudo apt install git
git clone https://github.com/pyenv/pyenv.git ~/.pyenv

Then you’ll need to update the ~/.bashrc file again this time to include pyenv.

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc

exec "$SHELL"

You’re then able to install any version of Python that pyenv has available.

pyenv install 3.10.8

Running Docker images with Podman

When installing Distrobox, we also installed podman as a dependency which means its also possible to run container images as we might do with docker. The command-line interface is very similar and podman’s homepage even suggests aliasing it to the docker command. This resolves one of the other problems when I first came to using the Steam Deck for programming.

podman run hello-world

I ran using Sebastián Ramírez’s uwsgi/nginx/flask image and it pulled and ran as expected.

podman run tiangolo/uwsgi-nginx-flask

Conclusion

Distrobox and podman really seem like they fix the problems I had getting programming tools set up on the deck and turn it into a very useful development machine. Definitely becomes a viable option for learning to program on.

Subscribe for Exclusives

My monthly newsletter shares exclusive articles you won't find elsewhere, tools and code. No spam, unsubscribe any time.