Automate Project Environments with Devbox and Direnv
The article emphasizes the benefits of isolated project environments and introduces Devbox and Direnv as tools to automate environment management. It explains their features, integration, and simplification of setting up project environments.
Read original articleThe article discusses the importance of having isolated environments for projects and introduces Devbox and Direnv as tools to automate and manage project environments effectively. It highlights the challenges of managing multiple projects on the same operating system and explains how Devbox simplifies the process of creating isolated shell environments. Direnv is presented as a tool that automates environment configuration on a per-directory basis, making it easier to manage different environments and switch between them seamlessly. The integration of Devbox and Direnv eliminates the need to set up .envrc files manually, streamlining the process of initiating project environments. The article provides a step-by-step guide on setting up a sample project with Devbox and Direnv, showcasing how to automate starting a NodeJS project. By combining Devbox and Direnv, developers can create and work in isolated development environments efficiently, enhancing their workflow.
Related
FreeBSD Bhyve Companion Tools
The author details transitioning from VirtualBox to FreeBSD Bhyve, praising Bhyve's benefits in a FreeBSD setting. Tools like VNC connection and pause/resume scripts optimize Bhyve operations, simplifying VM management.
From Dotenv to Dotenvx: Next Generation Config Management
Evolution from dotenv to dotenvx, a configuration tool addressing .env file leaks, multi-environment management, and platform inconsistencies. Offers encryption, uniform commands, and enhanced security. Version 1.0.0 released, promising future utilization.
Developer experience: What is it and why should you care? (2023)
Developer experience (DevEx) optimizes software development by empowering behaviors naturally. It enhances productivity, satisfaction, and collaboration among developers, leading to improved business outcomes. Generative AI and continuous feedback play key roles in DevEx advancement.
Developing Inside a Container
The Visual Studio Code Dev Containers extension allows developers to create a development environment within a container, ensuring consistent tool access and runtime stacks. Users need Docker installed and can enhance functionalities with extensions like Remote Development.
In Praise of Low Tech DevEx
The article explores Low-Tech DevEx (LTD) in developer tools, favoring text-based options like vim and make for portability, speed, and user-centric design. It promotes Unix principles for improved developer productivity.
I'm a bit confused. Direnv is rather simple, is it not.. ?
1. put env variables into .envrc 2. direnv allow
I don't use nix and I don't think I'm over its learning curve. I don't remember investing any time into it..
But if you are comfortable with Nix you don't need Devbox per se, as you can get by with using Flakes. Here are some examples -- just `git clone` and run `direnv allow` (once), then you are put in the corresponding devShell
Haskell: https://github.com/srid/haskell-template
Rust: https://github.com/srid/rust-nix-template
home-manager: https://github.com/juspay/nix-dev-home
I add .envrc to not only avoid committing it to projects that don't use it, but also because it turns out that it's still pretty environment dependent. There's 100 different ways to skin the dependency problem: Nix, pipenv, nvm, rustup, etc. There's no telling which a contributor prefers to use, so .envrc doesn't belong in git IMHO. What could be committed is something like .envrc-flake (which can then be sourced into .envrc).
As for needing a flake in the repo, I have found a workaround. `use flake` accepts parameters, including the path to the flake. I have a bunch of shells[2] that I can import with e.g. `use flake ~/Nix#rust`.
[1]: https://codeberg.org/jcdickinson/nix/src/branch/main/home/co... [2]: https://codeberg.org/jcdickinson/nix/src/branch/main/flake.n...
Regardless of the distro or even OS. An easy thing to say, but hard to execute on actual projects with patched versions of cPython and some obscure in-house build tool.
Also, as a benefit, by tracking the JSON and lockfile, the CI can work with the exact same environment. I highly recommend giving it a try.
They mention Nix but I guess they are referring to the use_nix integration built-in to direnv? There is a fairly detailed (but old) comparison in https://github.com/direnv/direnv/wiki/Nix#some-factors-to-co... and in the meantime lorri and nix-direnv are the only ones still maintained. But you aren't limited to Nix when using direnv, for example there is nvm. https://github.com/direnv/direnv/wiki/Node#using-nvm
Actually, the post's solution, besides being built on top of direnv, uses Devbox, which itself is built on top of Nix... https://www.jetify.com/devbox/docs/faq/#how-does-devbox-work So they are saying they are outside the Nix ecosystem when in fact they are in it. It is yet another set of nice scripts on top of Nix.
In case you hadn't realised, the very concept of having two sets of binary distributions on one machine, vying for superiority and the correct version of glibc... is fraught.
Most of my use was with rails projects, and I can't recommend it.
Coupled with an abstraction that tries to save you from Nix, but almost entirely fails, you end up with a bloated hellscape where every time you load your project it will unnecessarily reinstall your packages and several times an hour it will have forgotten curl exists and so you have to manually reinstall curl (not-so-slowly increasing your /nix folder's size), every week or two a new version of devbox completely changes the workarounds you need to do, and don't try to garbage collect nix or it will delete vital files, and you end up scrubbing it all and starting again.
In python, it overrode the path so I couldn't get it to reliably use the binaries in the venv. Pip and Python were using packages in different places and I couldn't get them to converge for love nor money.
The devbox team were great and really tried to get things working, but in the end I couldn't get it to work with enough stability to properly recommend it to my team, and if I wanted it to half-work for any substantial length of time I had to lock to a version of devbox.
Obviously, ymmv, please do give it a try, it's an impressive project. But my view is that it's trying to do something that is very very hard, and for that you need a very clever solution. And this is a very clever solution, with very clever bugs, and so it's not something I'd recommend jumping into with both feet.
Also, any solution of this kind will inevitably introduce a number of new problems proportionate to the internal complexity of such solution. I.e. this is just asking for a lot of problems, while offering very little in return.
Related
FreeBSD Bhyve Companion Tools
The author details transitioning from VirtualBox to FreeBSD Bhyve, praising Bhyve's benefits in a FreeBSD setting. Tools like VNC connection and pause/resume scripts optimize Bhyve operations, simplifying VM management.
From Dotenv to Dotenvx: Next Generation Config Management
Evolution from dotenv to dotenvx, a configuration tool addressing .env file leaks, multi-environment management, and platform inconsistencies. Offers encryption, uniform commands, and enhanced security. Version 1.0.0 released, promising future utilization.
Developer experience: What is it and why should you care? (2023)
Developer experience (DevEx) optimizes software development by empowering behaviors naturally. It enhances productivity, satisfaction, and collaboration among developers, leading to improved business outcomes. Generative AI and continuous feedback play key roles in DevEx advancement.
Developing Inside a Container
The Visual Studio Code Dev Containers extension allows developers to create a development environment within a container, ensuring consistent tool access and runtime stacks. Users need Docker installed and can enhance functionalities with extensions like Remote Development.
In Praise of Low Tech DevEx
The article explores Low-Tech DevEx (LTD) in developer tools, favoring text-based options like vim and make for portability, speed, and user-centric design. It promotes Unix principles for improved developer productivity.