Skip to main content

Adding Devbox to your Project

Background

Devbox is a command-line tool that lets you easily create reproducible, reliable dev environments. You start by defining the list of packages required by your development environment, and devbox uses that definition to create an isolated environment just for your application. Developers can start their dev environment by running devbox shell within your project.

To learn more about how Devbox works, you can read our introduction

This Quickstart shows you how to install Devbox and use it to create a new Development Environment for your project.

Prerequisities

Devbox requires nix to be installed.

Install Devbox

Use the following install script to get the latest version of Devbox:

curl -fsSL https://get.jetpack.io/devbox | bash

Create a development environment

We’ll create a new development environment with the packages we need. These packages will only be available when using this Devbox shell, ensuring we don’t pollute your machine.

  1. Open a terminal in a new empty folder.

  2. Initialize Devbox:

    devbox init

    This creates a devbox.json file in the current directory. You should commit it to source control.

  3. Add command-line tools from Nix Packages. For example, to add Python 3.10:

    devbox add python310
  4. Your devbox.json file keeps track of the packages you've added, it should now look like this:

    {
    "packages": ["python310"]
    }
  5. Start a new shell that has these tools installed:

    devbox shell
    info

    The first time you run devbox shell may take a while to complete due to Devbox downloading prerequisites and package catalogs required by Nix. This delay is a one-time cost, and future invocations and package additions should resolve much faster.

    You can tell you’re in a Devbox shell (and not your regular terminal) because the shell prompt and directory changed.

  6. Use your favorite tools.

    In this example we installed Python 3.10, so let’s use it.

    python --version
  7. Your regular tools are also available including environment variables and config settings.

    git config --get user.name
  8. To exit the Devbox shell and return to your regular shell:

    exit

Add the Devbox Badge to your Repo

Once you publish your Devbox project to Github, you can help other developers get started by adding the Devbox Badge to your repo. Please copy the code snippets below and paste them into your README.md to add the badge

Devbox Dark Badge

[![Built with Devbox](https://jetpack.io/devbox/img/shield_galaxy.svg)](https://jetpack.io/devbox/docs/contributor-quickstart/)

Devbox Light Badge

[![Built with Devbox](https://jetpack.io/devbox/img/shield_moon.svg)](https://jetpack.io/devbox/docs/contributor-quickstart/)

Next Steps

Learn more about Devbox

  • Devbox Scripts: Automate setup steps and configuration for your shell using Devbox Scripts.
  • Configuration Guide: Learn how to configure your shell and dev environment with devbox.json.
  • Browse Examples: You can see how to create a development environment for your favorite tools or languages by browsing the Devbox Examples repo.

Use Devbox with your IDE

  • Direnv Integration: Devbox can integrate with direnv to automatically activate your shell and packages when you navigate to your project.
  • Devbox for Visual Studio Code: Install our VS Code extension to speed up common Devbox workflows or to use Devbox in a devcontainer.

Get Involved