Devbox 0.4.7: Services 2.0 + Flake Support

Define custom services and import package from Flakes with Devbox 0.4.7

Devbox 0.4.7: Services 2.0 + Flake Support
Announcing Devbox 0.4.7

Devbox 0.4.7 comes with two major new feature requested by users:

  1. Services 2.0, which improves how devbox services works and allows users to define their own custom services
  2. Flake Support, which lets users install packages from Nix Flakes hosted on Github, or their own custom flakes
  3. Direnv Integration Improvements, which improves the fidelity and performance of our direnv integration.

To install the latest version of Devbox, visit our Getting Started guide. If you already have Devbox installed, version 0.4.7 will be pushed to you automatically. You can view the full release notes on Github.

Services 2.0: Process Compose and User Services

This release includes a major revamp to devbox services that simplifies defining and managing your own services.

Devbox Services are now backed by Process Compose, an open source process manager that provides an interactive TUI for monitoring your running services. You can start the TUI, along with all your services, by running devbox services up . If you’d rather run your services without starting the TUI, you can run devbox services up -b to start process-compose in the background

Screenshot of the Process Compose TUI

You can now define your own custom services and processes in a process-compose.yml. Defining services is useful if you want to easily start your application and or other processes Here is an example process-compose.yaml that can run a Django server:

version: "0.5"

	 # Command to run and manage in process compose
   command: python todo_project/ runserver
   # Restart policy for the process
    restart: "always"

Once your Devbox services are running, you can manage them in the TUI, or  using devbox services start|stop|restart. If you have services running in multiple Devbox projects, you can stop them all using devbox services stop --all-projects

If you'd like to see the new feature in action, click below for a short video of the new Devbox Services feature in action. You can also learn more by visiting our Docs.

Devbox Services 2.0 Demo

Flake Support

Nixpkgs is a massive collection of over 100,000 buildable packages for the Nix package manager. It provides a vast selection of software for developers to leverage in their projects. However, we've heard from our customers that they want to install packages unavailable in Nixpkgs, including packages they've built or customized locally.

With 0.4.7, we’re introducing Flake support. Developers can now install packages from Github-hosted flakes or custom flakes on their local machine. Developers can source packages using a Flake reference, which describes the Flake's location and outputs, in the packages section of their devbox.json. You can even use a Flake reference to install a package from a specific commit or channel of Nixpkgs:

 "packages": [
      // Add the default package from the numtide/flake-utils repo on Github
      // Install a specific output from the nix-community/fenix flake
      // Install the hello package from a specific channel(branch) of Nixpkgs
     // Install a package from a local flake. 
     // This should point to a directory that contains a flake.nix file.

You can learn more about Flakes in our documentation, or by checking out some examples in the Devbox Repo:

Direnv improvements

For the last few releases, we’ve focused on improving the correctness and performance of our Direnv integration. In addition to the features listed above, 0.4.7 includes some major improvements to our Direnv integration:

  1. We removed the use nix .devbox/gen/shell.nix invocation from the generated .envrc file. This line was no longer necessary after we moved our backend to Flakes, and removing it should speed up Direnv generation time
  2. Generated shell environments are now cached. This should speed up startup times for run, shell, and .envrc activation
  3. We now run init_hooks as part of our .envrc hook. While this may introduce a small amount of latency when activating your environment, it ensures that the environment created by direnv matches your Devbox shell
  4. Devbox will now ensure that the packages specified in your devbox.json are installed when generating your .envrc.  This ensures that your init_hooks and environment will run as expected.

If you’ve been using the direnv integration with Devbox, you should regenerate your .envrc to get the latest improvements by running devbox generate direnv --force.

Bug Fixes and Performance improvements

Finally, Devbox 0.4.7 also includes various bug fixes and improvements, including a bugfix that ensures environment variables are retained between package calls.

You can view the full diff and release notes for 0.4.7 on our Github Release Page

Thanks to all our supporters and contributors who helped make this release possible! 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.