DEV Community

mtwtkman
mtwtkman

Posted on

I made a small script as distrobox thin wrapper

TL;DR

I made a (very personally) light bash script named boxkit for setup routine of a development container created by distrobox to be more handy.
Please refer https://github.com/mtwtkman/boxkit

Why and what for

I love distrobox's approach to create new development environment, basically I create an indivisual development container against one project.
That works well, but I have to setup development configurations which are almost same tools like ripgrep and fzf, vim and different tools at different times.

boxkit provides those functionalities via generating a simple thin wrapper of distrobox and a configured distrobox manifest file.

I can say this script is jsut a cookiecutter for each environment.

Architecture

boxkit command

boxkit itself is a single script for installing main assets.

Once you run boxkit script then one executable bash script named box (default) and distrobox.ini in you current directory.

box command

box (default name) is an executable bash script for manipulating container via distrobox command.
box has three subcommands like below.

  1. box enter equals to distrobox enter
  2. box init is initial setup like creating symlink and envvars, .bashrc
  3. box stop equals to distrobox stop

Why do I need box enter and box stop? Those commands look just aliases for distrobox.
Almost Yes. Short answer is just for unity.

Actually both commands are more conditional than distrobox enter because box enter detect current active development container name and changes behaviour by existance of the container.

Now box is very personally defined, so I recommend that you fork and custom it.

# How `box enter` do:
[ "${CONTAINER_ID}" ] && exit 0
[ ! "$(distrobox list | rg ${container_name})" ] && create_box
[ "$#" = 1 ] && [ "$1" = "-r" ] && create_box
distrobox enter "${container_name}"

# How `box stop` do:
[ "${CONTAINER_ID}" ] && exit 0
[ ! "$(distrobox list | rg ${container_name})" ] && exit 0
distrobox stop ${container_name}
Enter fullscreen mode Exit fullscreen mode

Those conditional functionalities reduces little a bit annoying.

configured distrobox manifest file

boxkit generates a distrobox.ini. Which is one of core purpose.

This generated file (or boxkit's concept) regards the development container must be isolated environment from host machine's one.
So this file is configured home option.

Though home directory for the development container is separated, advantates of distrobox is not dead because box init provisioned symlinks for some configuration of my needed packages.

Conclusion

distrobox is so neat and powerful for me. But when I use heavily it, I notice that there are some routines and I'm bothered.
So I made a thin wrapper for distrobox setup to be happy development and this approach works well so far.

Top comments (0)