Devbox 0.4.3: Powered by Flakes
With Devbox 0.4.3, we've fully shifted our environment generation from using standard Nix expressions to using Nix Flakes, a new experimental feature in the Nix ecosystem.
While this is mostly a behind the scenes change to Devbox, we're excited about the potential this unlocks, and we wanted to share why we made this shift. In this post we'll describe why Flakes are so important, and the benefits our users should see from this change.
To install the latest version of Devbox, visit our Getting Started guide. If you already have Devbox installed, version 0.4.3 will be pushed to you automatically. You can view the full release notes on Github.
What are Flakes?
Flakes are a new feature in the Nix language that lets us package software and create development shells in a declarative, fully reproducible way. They provide several advantages compared to the traditional way of defining Nix environments:
- Flakes provide a simplified, standardized format for declaring the inputs to your development environment, whether a specific commit of the Nixpkg repo, another flake, or a tarball. This standardization makes composing multiple inputs and sources into a shell much more manageable.
- Flakes also generate a lockfile of your inputs and packages, ensuring your shell is reproducible whenever you run it. In addition to pinning the versions of your packages, the lockfile makes it easier to update your inputs atomically to newer versions.
- Because flakes are more hermetic and reproducible, we can cache the results of evaluating them. Caching these outputs means your shell and scripts can run much faster.
With all these features, you can see why flakes are quickly becoming the preferred way to build and develop in the Nix ecosystem. For Devbox, our move to flakes means we can build faster, more reproducible development environments for all of of our user's projects.
If you're curious and want to learn more about flakes, here are a few good resources to check out:
- Practical Nix Flakes - Serokell.io
- A List of Beginner Friendly Flakes - NixOS Discourse
- A Tour of Nix Flakes - Ghedam.mat
- NixOS Wiki Entry on Flakes
What This Means for Users
This initial release is mainly behind the scenes, and no user workflows will change — you can keep using Devbox exactly how you’ve been using Devbox to this point. However, users should see a significant improvement in startup times as a result of this shift.
Because Flakes provide better caching of our Nix evaluations, we can start Devbox shells faster than ever. In our testing, we've seen as much as a 70% improvement in warm startup time over Devbox 0.4.2 . Below is a typical comparison run on macOS, using the Ruby example in our examples repo:
That's a nearly 4x improvement as a result of moving to Flakes!
In addition to these performance improvements, the reproducibility and easy version upgrades of Flakes will unlock a lot of new features for Devbox. Some features we are planning include:
- The ability to add packages from multiple sources, including flakes or Git repos outside of nixpkgs
- Atomic updates to the latest versions of your packages, without having to find and change the commit hash in your shell.
- Fast package search from the Devbox CLI
Keep in Touch
We're excited for all the new features that flakes will unlock for Devbox! If you'd like to keep up with our progress, you can follow us on Twitter, or chat with our developers on our Discord Server. We also welcome issues and pull requests on our Github Repo.