Updated: 2023-12-12 Tue 22:06

Quick Tip: using recent Software with Distrobox

If you are not using a rolling release distro, it can sometimes be frustrating to depend on more or less outdated software. Mostly, I don't care about the newest and shiniest thing. I could not care less if I use this or that version of libreoffice. But sometimes it can be nice to use something newer. In my case, I use the emacs text editor (doom) a lot. The version available with apt is 27.1 which was released at this point over 3 years ago. Normally, if I would want the newest stable version 29.1, I would have to compile it from source, which i do not bother to do. But with Distrobox, there is a easy and conveniant way to get recent software on your computer.

What is Distrobox1?

Distrobox lets you use any (relevant) linux distribution in the terminal. This in it self is not that special, but the created distroboxes are tightly integrated with the host. This means that you have access from your virtualized environment to your local homefolder, which has both positive and negative implications. For our purposes and in combination with Distroboxes export-feature we can create a nearly seemless experience. Let me show you:

How to get recent software with the example of emacs

First, lets install Distobox:

sudo apt install distrobox

You will also need a container manager: podmand, docker and/or lilipod. Look into the documentation for more info.

sudo apt install podman

Once installed, you are ready to create your first distrobox. You could create any of the compatible container-distributions from the website, where the "toolbox"-versions have a fuller toolkit and are generally what you want. For our purposes, we will create an arch-box to get access to the AUR:

distrobox-create arch --image quay.io/toolbx-images/archlinux-toolbox:latest

then:

distrobox-enter arch

Now your prompt should have changed to something like username@arch. You are now in a virtualized arch environment. First, ensure your package-database is up to date and install emacs:

sudo pacman -Sy
sudo pacman -S emacs

Now you should already be able to run emacs from your arch-terminal and have a running and usable instance of emacs. For me, i use a flavor of emacs called doom-emacs, so I quickly show you some additional steps for doom:

sudo pacman -S git ripgrep

git clone --depth 1 https://github.com/hlissner/doom-emacs ~/.emacs.d
~/.emacs.d/bin/doom install

doom sync

The last step is to export the application to the host, so it can be accessed like any other desktop-application:

distrobox-export --app emacs

Now you should be able to access the newest version of emacs (from arch) from your run launcher of choice.

Footnotes:

Emacs 28.2 (Org mode 9.5.5)