I.M Blogging

Distrobox Is Why We Can Have Nice Things

In my last blog post I went over the best ways to get Nix working on Debian, so you could get tons of new packages on the system in a stable way. Not even a month later I found out about Distrobox which is a tool based around containerization, allowing you to bring any package manager and package repository to your distro of choice.

Is Distrobox Right For You?

Distrobox is essentially a wrapper around a container engine. That creates lightweight and highly transparent containers, bringing the user land of any containerized Linux OS to your current system. This can do lots of great things especially with development work, but another great use is an expansion to what package managers you can use. This becomes even easier with Distrobox's ability to export binaries out of the containers and into your regular Linux system. Making it even easier to install and manage programs not naively available through your distro.

Setup

Installing and setting up Distrobox is a breeze on most systems, as the only requirement besides Distrobox itself is a container engine. Specifically Podman, Docker, or Lilipod. I recommend Podman, but any of these are fine. Installing a container engine on most distros is a straight forward process, and better covered in other resources. You should look at both your distros documentation and packages along with the official instructions of your desired engine. I myself used nix to get everything onto my system.

EngineDocumentation
Podmanhttps://podman.io/docs/installation
Dockerhttps://docs.docker.com/engine/install/
Lilipodhttps://github.com/89luca89/lilipod?tab=readme-ov-file#getting-started

After you've confirmed you container engine is working a-okay, Distrobox is already packaged in these distributions (look under repositories for your distro). This should have you covered, but in the odd case you can't there are also alternative methods documented.

Basic Usage

Distrobox has a pretty simple CLI and good documentation as well, but if you want the basics form me, they are based around the distrobox create and distrobox export. The first allows you to make a box while also configuring what base image to use (--image), hooks to execute (--init-hooks or --pre-init-hooks) as well as other options. You can also use .ini files and distrobox assemble to declarative configure boxes. Export is what allows you to push binaries out of the container and into the host OS. Which makes expanding the packages you have access to trivially easy. The rest of the commands concern managing your boxes. There is also a good GUI you can use if you want to skip over a lot of the command line stuff.

Getting the AUR Working on Debian

Warning: AUR packages are user-produced content. These PKGBUILDs are completely unofficial and have not been thoroughly vetted. Any use of the provided files is at your own risk. – Arch Wiki

Now that you understand some of the basics of Distrobox, I want to show something fun that you can do with all of this. Which is getting the AUR working on Debian. It was honestly a lot easier then I thought it was going to be. First use this config as the base for where you'll put all the AUR packages.

[aur]
additional_packages="neofetch"
image=quay.io/toolbx/arch-toolbox:latest
init=true
nvidia=false # nvidia seems to not work with the arch image
pull=true
root=false
replace=false
start_now=true

After using distrobox assemble you'll end up with a basic arch system and you can already get regular arch packages, and AUR packages using git clone and makepkg. Though I like using a helper program to make it easier to manage the system. yay is a very popular option which can be installed quite simply with the below commands while in the aur box.

git clone https://aur.archlinux.org/yay.git && \
cd yay && \
makepkg -si

Which you can use to install packages from the AUR or regular repositories.

yay -S [PACKAGENAME]

Also don't forget to export the binaries out of the box if you want the base OS to have access to them.

distrobox export --app [PACKAGENAME]

Tags: