Toolbx (with Arch, btw)

2024-12-22

As I outlined in my previous post, I am currently using Fedora Silverblue on my personal notebook to try out an immutable Linux distribution. The most significant difference to my previous setup is how the command line experience changes. A huge part of my work is happening in terminals, so this is important to me.

Installing Toolbx and Ptyxis

Fedora Silverblue ships with Podman and Toolbx (both part of the containers project) pre-installed: After I tried out the combination of Toolbx and Ptyxis on my personal laptop, I’m now also using it on my work machine, which is running Debian 12.

I installed them like this:

sudo apt install podman-toolbox
flatpak install flathub app.devsuite.Ptyxis

Toolbx

I’ve chosen Arch as the distro inside of Toolbx for a simple reason: It has a vast number of up-to-date packages1. I did not expect it, but I’m really impressed by the speed of pacman compared to apt. It is a bit unusual for me, as some packages are either not installed by default or have been split into multiple packages. But I really like it so far. So how does this work?

If you ran a container via Podman both package management and interaction with the host would be a bit awkward. Toolbx is a wrapper around Podman that helps you with that. The team provides container images for a few distros, you can get them from Red Hat’s container registry Quay. So we will choose the Arch container:2

toolbox create --image quay.io/toolbx/arch-toolbox

You can now enter the container with:

toolbox enter arch-toolbox

Now, we are running on Arch Linux and can install packages via pacman. I prefer the fish shell and the vim editor, so here we go:

pacman -Syu fish vim

Don’t ask me who thought this would be a reasonable user interface for a package manager. But we have fish and vim installed! Type fish and enter the wonderful world of the friendly interactive shell. Now, install all the other tools you want to use on the command line (this is my list of CLI tools). You can also run only a single command in the container from your host:

toolbox run pacman -Syu bat

Ptyxis

Now, it would be a bit awkward to first run toolbox enter and then fish in every terminal window we open. This is why Ptyxis, the pre-installed terminal emulator on Silverblue, offers an integration with Toolbx. Open the settings, and click on profiles. Create a new profile (I called mine Arch, btw), select your preferred color scheme, and then scroll down to “Default Container”. Here, you can select the arch-toolbox container we created. If you, like me, want to use fish, go to the Shell section and check “Use Custom Command” and enter /usr/bin/fish. Done! Now open a new tab with the Arch profile, and you will be in your Arch toolbox in fish. Beautiful!

Screenshot of the Ptyxis profile settings showing the option to set the default container and default command

I created a second profile called System. It uses “My computer” as the default container. This way, I can open a new tab for when I need to do something outside the toolbox. This has been very rare so far, so my default profile is the Arch one. I also chose a different color scheme for this other profile so I am able to tell them apart.

Podman & Breaking out of the box

It is important to note that this container is not as isolated from the base system as containers typically are. This is not a security feature. It makes it super easy to wipe it, and start from scratch, though. And we can benefit from a tight integration with the host: It is slightly mind-blowing to me that tools like wl-copy and wl-paste work between the host and the container.

You can also run commands on the host from within your toolbox with flatpak-spawn. I’ve created several aliases. I only create them when running inside of a Toolbx by testing if the file /run/.toolboxenv exists. Here are a few examples:

if test -f "/run/.toolboxenv"
  alias podman="flatpak-spawn --host podman"                                                                                                                          
  alias flatpak="flatpak-spawn --host flatpak"
  alias firefox="flatpak-spawn --host firefox"
  alias gsettings="flatpak-spawn --host gsettings"
  # ...

This also allows me to start containers from my toolbox. As the toolbox is a Podman container itself, they are running alongside it on the host. I always run Postgres in a container, so I don’t need to change anything about my workflow3:

podman run -p 5432:5432 --rm docker.io/library/postgres

Now, it can be accessed by the Ruby and Node apps I run in the toolbox. It is kinda cool to me that when I run podman ps I see both containers running side by side now.

Conclusion

I thoroughly enjoy this setup. With Toolbx, I can use the up-to-date packages from Arch on a stable base system. If I mess something up, I can throw away the container and start from scratch. Ptyxis (even though difficult to type) makes Toolbx seamless.

Thanks

Thanks to Bascht and mkhl for their feedback ❤️

Footnotes

  1. The only tool I’m missing compared to nix is xe. It is only available via AUR, and I didn’t go down that road yet. 

  2. You can see the source for that container here 

  3. I use a small script for running Postgres