A wrapper around distrobox
or toolbox
to provide commands which exist in a dev container, in the host environment transparently.
Heavily inspired by nix-direnv.
Put the following lines in your .envrc
:
if ! has box_direnv_version || ! box_direnv_version 0.1.0; then
source_url "https://raw.githubusercontent.com/thesola10/box-direnv/0.1.0/direnvrc" "sha256-pznp4/w7UzNAqreaLuGgq4/CTFjMedC376xnIWr5s+U="
fi
box-direnv
supports a few scenarios, depending on the parameters given:
Create a distrobox.ini
file in your project root, which will describe the Distrobox container providing your environment, then add the line use distrobox
:
$ echo "use distrobox" >> .envrc
$ direnv allow
Optionally, you can specify a box name:
$ echo "use distrobox my_box" >> .envrc
$ direnv allow
Add the line use distrobox <image>
or use toolbox <image>
to tell box-direnv to create a container from that image. For example:
$ echo "use distrobox registry.fedoraproject.org/fedora-toolbox"
$ direnv allow
You may wish to customize your container image before entering the environment. In this case, you can tell box-direnv to use a local build context directly.
Add the line use distrobox <path to Containerfile>
or use toolbox <path to Containerfile>
to tell box-direnv to build an image from that directory, then use it to create the container. For example:
$ echo "use toolbox ./docker"
$ direnv allow