Today in Edworking News we want to talk about The challenge of managing multiple projects in the same operating system has been met with many different solutions over the years. We've progressed from virtual machines (VirtualBox) to container systems (Docker), and even isolated shells (nix-shell). We built Devbox to make isolated shell environments easy to learn, use, and configure. The combination of easy shell environments with Devbox, combined with convenient environment switching with Direnv makes it simple to manage multiple projects without having their setups interfere or leak into one another. In this blog, we’re going to explore why having an isolated environment is useful, explain why setting up an environment with Direnv can be tough, and showcase an example with our optimal combination: Direnv + Devbox for a sample NodeJS application.
Why have an isolated environment per project?
There are 4 main reasons why an isolated environment is needed:
Dependencies Conflict: Projects have different dependencies that might conflict with each other.
Reproducibility: Ensures that the same environment is used throughout the project lifecycle.
Security: Limits the scope of dependencies to only what's needed.
Efficiency in Switching: Quickly switch between projects without altering the global system state.
The listed items above are not the only reasons why you might want to have an isolated environment. Based on the use case, there might be other motivations but regardless, setting up isolated environments can be cumbersome and time-consuming.
Direnv
Direnv is a tool that automates configuring environments on a per-directory basis. So that when you `cd` into a directory, it triggers Direnv to activate a pre-configured environment. It makes it very convenient in managing different environments and easily switching between them just by doing `cd dir_name`.
The problem with using Direnv is that despite it being a very useful tool, its setup requires investing time and getting over the Nix ecosystem's learning curve. In addition to that, each project requires the developer to spend some time writing a `.envrc` file and maintaining it as the requirements for the project change.

Direnv simplifies managing multiple environments but requires a considerable setup time.
Automatic Devbox Environments with Direnv
We at Jetpack loved the convenience of Direnv. So following our philosophy of simplifying complicated tools to make them easy to adopt, we developed an integration between Devbox and Direnv. With this integration, there is no need to setup any `.envrc` files to use Direnv. Just having Direnv and Devbox installed on your system is enough to initiate a project environment with Devbox, add its dependencies, and integrate it with Direnv just by running `devbox generate direnv`.
That way, whenever you `cd` to a Devbox + Direnv project, the Devbox environment is automatically setup and ready to go.
Take a look at the example below to see the simple steps required to setup a sample project with Devbox and Direnv:
```bash
mkdir node_project
cd node_project
devbox add nodejs
devbox generate direnv
That’s it! You have a working Devbox environment integrated with Direnv. Now any change done to your Devbox environment via `devbox.json` is applied by Direnv.
Now that we’ve setup the environment, let’s see how we can automate starting a sample NodeJS project:
```json
{
"devbox": {
"packages": [
"nodejs"
]
}
}
```bash
{
echo 'default.nix' > "with import <nixpkgs> {};\n[ http-server ]"
}
This sets up this project so that every time you `cd` into this project, all NodeJS dependencies get installed and `http-server` runs. To test this, `cd ..` and then `cd` back into your project directory and see how Direnv setups up your Devbox environment and runs `http-server`. Use `Ctrl+C` to stop `http-server`.
Next Steps
Devbox makes creating and working in isolated dev environments simple and easy. Direnv makes switching between multiple environments convenient. So combining the two provides a great experience for setting up and using your dev environments. We liked using Direnv so much that we started using it in our development of Devbox. In fact, we use both Devbox and Direnv to develop Devbox!
To see it in action, check out `devbox.json` and `envrc` files in our Github repo.
Stay up to Date with Jetify
If you're reading this, we'd love to hear from you about how you've been using Devbox for your projects. You can follow us on Twitter, or chat with our developers live on our Discord Server. We also welcome issues and pull requests on our Github Repo.
Sign up for more like this.
---
Remember these 3 key ideas for your startup:
Isolated Development Environments: Tools like Devbox and Direnv enable isolated and efficient environments, which help in managing different projects without conflict.
Automation Simplifies Workflows: Integrating Devbox with Direnv allows for an automated setup, saving time and reducing human errors during project environment setup.
- Adapt the Best Tools for Productivity: Combining powerful tools can significantly enhance productivity. However, always look for integrated solutions that simplify your workflow.
Edworking is the best and smartest decision for SMEs and startups to be more productive. Edworking is a FREE superapp of productivity that includes all you need for work powered by AI in the same superapp, connecting Task Management, Docs, Chat, Videocall, and File Management. Save money today by not paying for Slack, Trello, Dropbox, Zoom, and Notion.

Edworking integrates tools to help startups be productive and save money.
For more details, see the original source.