I replaced Homebrew and asdf with Devbox
In the last years, I used a combination of homebrew and asdf to manage some developer tools (eg. terraform, hadolint, ShellCheck, …)
Recently I discovered devbox, a wrapper around NixOS package manager.
First install Devbox:
curl -fsSL https://get.jetify.com/devbox | bash
Now, everytime I initialize a new project, instead of installing asdf plugins and
declare it on .tool-versions, I just add the dependencies on devbox.json on the
root of each project. First I run
devbox init
To create an empty devbox.json in the project directory.
Here it is an example for a python project using poetry to manage python packages.
{
"packages": [
"python@latest",
"poetry@latest"
],
"shell": {
"init_hook": [
"poetry install"
],
"scripts": {
"run_test": "poetry run python -m poetry_demo",
"test": "poetry run pytest"
}
}
}
Since I use VSCode, I installed the extension devbox by Jetify.
This way, when VSCode terminal is opened on a devbox project, this extension detects devbox.json
and runs devbox shell so terminal is automatically in devbox shell environment.
If you use other IDE, devbox can integrate with direnv to automatically activate your
shell and packages when you navigate to your project.
To install some tool system-wide, like ripgrep, use the following command:
devbox global add ripgrep
To see what packages you already have installed:
devbox global ls