Skip to content

Commit f884348

Browse files
authored
[devbox] Correctly pass path to nix and improve README (#2599)
## Summary `devbox shell` used to (accidentally) change your working directory. We now pass the path to `nix` in a way that retains the current working directory. Improve README ## How was it tested? Built and ran locally. ## Is this change backwards-compatible? Yes.
1 parent 4cd4626 commit f884348

File tree

5 files changed

+55
-35
lines changed

5 files changed

+55
-35
lines changed

README.md

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,50 @@
1-
# Devbox: instant, easy and predictable development environments.
1+
# Devbox 📦
22

3-
[![release](https://github.com/jetpack-io/devbox/actions/workflows/release.yml/badge.svg)](https://github.com/jetpack-io/devbox/actions/workflows/release.yml)
4-
![Apache 2.0](https://img.shields.io/github/license/jetpack-io/devbox)
3+
### Instant, easy, and predictable shells and containers
54

6-
With Devbox, you can easily create deterministic shells with preinstalled utilities without polluting your machine with contradictory versions.
5+
[![Join Discord](https://img.shields.io/discord/903306922852245526?color=7389D8&label=discord&logo=discord&logoColor=ffffff)](https://discord.gg/agbskCJXk2) ![License: Apache 2.0](https://img.shields.io/github/license/jetpack-io/devbox) [![version](https://img.shields.io/github/v/release/jetpack-io/devbox?color=green&include_prereleases&label=version&sort=semver)](https://github.com/jetpack-io/devbox/releases)
76

8-
Want to try out a tool but don’t want the mess? Add it to a Devbox shell.
7+
---
98

10-
<iframe width="560" height="315" src="https://www.youtube.com/embed/WMBaXQZmDoA" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
9+
## What is it?
1110

12-
## Compatibility
11+
Devbox is a command-line tool that lets you easily create isolated shells and containers. You start by defining the list of packages required for your development environment, and devbox uses that definition to create an isolated environment just for your application.
1312

14-
Devbox works on:
13+
In practice, Devbox works simlar to a package manager like `yarn` – except the packages it manages are at the operating-system level (the sort of thing you would normally install with `brew` or `apt-get`).
1514

16-
- Linux
17-
- macOS
18-
- Windows via WSL2
15+
Devbox was originally developed by [jetpack.io](https://www.jetpack.io) and is internally powered by `nix`.
1916

17+
![screen cast](https://user-images.githubusercontent.com/279789/186473702-b65cf932-766c-4875-85d7-d77ebe68fe20.svg)
2018

21-
## Setup
19+
## Benefits
20+
21+
### A consistent shell for everyone on the team
22+
23+
Declare the list of tools needed by your project via a `devbox.json` file and run `devbox shell`. Everyone working on the project gets a shell environment with the exact same version of those tools.
24+
25+
### Try new tools without polluting your laptop
26+
27+
Development environments created by Devbox are isolated from everything else in your laptop. Is there a tool you want to try without making a mess? Add it to a Devbox shell, and remove it when you don't want it anymore – all while keeping your laptop pristine.
28+
29+
### Don't sacrifice speed
30+
31+
Devbox can create isolated environments right on your laptop, without an extra-layer of virtualization slowing your file system or every command. When you're ready to ship, it'll turn it into an equivalent container – but not before.
32+
33+
### Good-bye conflicting versions
34+
35+
Are you working on multiple projects, all of which need different versions of the same binary? Instead of attempting to install conflicting versions of the same binary on your laptop, create an isolated environment for each project, and use whatever version you want for each.
36+
37+
### Instantly turn your application into a container
38+
39+
Devbox analyzes your source code and instantly turns it into an OCI-compliant image that can be deployed to any cloud. The image is optimized for speed, size, security and caching ... and without needing to write a `Dockerfile`. And unlike [buildpacks](https://buildpacks.io/), it does it quickly.
40+
41+
### Stop declaring dependencies twice
42+
43+
Your application often needs the same set of dependencies when you are developing on your laptop, and when you're packaging it as a container ready to deploy to the cloud. Devbox's dev environments are _isomorphic_: meaning that we can turn them into both a local shell environment or a cloud-ready container, all without having to repeat yourself twice.
44+
45+
## Installing Devbox
46+
47+
In addition to installing Devbox itself, you will need to install `nix` and `docker` since Devbox depends on them:
2248

2349
1. Install [Nix Package Manager](https://nixos.org/download.html). (Don't worry, you don't need to learn Nix.)
2450

@@ -30,7 +56,6 @@ Devbox works on:
3056
curl -fsSL https://get.jetpack.io/devbox | bash
3157
```
3258

33-
3459
## Quickstart: Fast, Deterministic Shell
3560

3661
In this quickstart we’ll create a development shell with specific tools installed. These tools will only be available when using this Devbox shell, ensuring we don’t pollute your machine.
@@ -79,12 +104,11 @@ In this quickstart we’ll create a development shell with specific tools instal
79104
exit
80105
```
81106

107+
## Quickstart: Instant Docker Image
82108

83-
## Quickstart: Automatic Docker Image
109+
Devbox makes it easy to package your application into an OCI-compliant container image. Devbox analyzes your code, automatically identifies the right toolchain needed by your project, and builds it into a docker image.
84110

85-
With a Devbox environment, it’s simple to build the codebase into an OCI-compliant container image. Devbox will automatically detect your toolchain and pull in the correct Dockerfile.
86-
87-
1. Open a terminal in a Devbox folder (see above).
111+
1. Initialize your project with `devbox init` if you haven't already.
88112

89113
2. Build the image:
90114

@@ -96,29 +120,20 @@ With a Devbox environment, it’s simple to build the codebase into an OCI-compl
96120

97121
3. Tag the image with a more descriptive name:
98122

99-
```
123+
```bash
100124
docker tag devbox my-image:v0.1
101125
```
102126

103-
### Auto-detected languages:
104-
105-
- Go
106-
107-
Want more languages? [Ask for a new Language](https://jetpack-io.canny.io/devbox) or [Contribute one via Pull Request](https://github.com/jetpack-io/devbox/tree/main/tmpl)
108-
109-
110127
## Additional commands
111128

112-
`devbox help` - see all commands
129+
`devbox help` - see all commands
113130

114131
`devbox plan` - see the configuration and steps Devbox will use to generate a container
115132

116-
117133
## Related Work
118134

119-
Thanks to [Nix](https://nixos.org/) for providing isolated shells. Devbox is not affiliated with the NixOS project.
120-
135+
Thanks to [Nix](https://nixos.org/) for providing isolated shells.
121136

122137
## License
123138

124-
This project is proudly open-source under the [Apache 2.0 License](https://github.com/jetpack-io/devbox/blob/main/LICENSE) Copyright Jetpack Technologies, Inc.
139+
This project is proudly open-source under the [Apache 2.0 License](https://github.com/jetpack-io/devbox/blob/main/LICENSE)

devbox.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (d *Devbox) Shell() error {
9696
if err != nil {
9797
return errors.WithStack(err)
9898
}
99-
nixDir := filepath.Join(d.srcDir, ".devbox/gen")
99+
nixDir := filepath.Join(d.srcDir, ".devbox/gen/shell.nix")
100100
return nix.Shell(nixDir)
101101
}
102102

nix/nix.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
)
1414

1515
func Shell(path string) error {
16-
cmd := exec.Command("nix-shell")
16+
cmd := exec.Command("nix-shell", path)
1717
// Default to the shell already being used.
1818
shell := os.Getenv("SHELL")
1919
if shell != "" {
@@ -22,7 +22,6 @@ func Shell(path string) error {
2222
cmd.Stdin = os.Stdin
2323
cmd.Stdout = os.Stdout
2424
cmd.Stderr = os.Stderr
25-
cmd.Dir = path
2625
return cmd.Run()
2726
}
2827

tmpl/default.nix.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ let
88
}) {};
99
in with pkgs;
1010
buildEnv {
11-
name = "my-env";
11+
name = "devbox";
1212
paths = [
1313
{{- range .Packages}}
1414
{{.}}

tmpl/shell.nix.tmpl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ let
88
}) {};
99
in with pkgs;
1010
mkShell {
11-
shellHook = "export name=devbox IN_NIX_SHELL=0; DEVBOX_SHELL_ENABLED=1;";
11+
shellHook =
12+
''
13+
echo "Starting a devbox shell..."
14+
export name="devbox"
15+
export IN_NIX_SHELL=0
16+
export DEVBOX_SHELL_ENABLED=1
17+
'';
1218
packages = [
1319
{{- range .Packages}}
1420
{{.}}

0 commit comments

Comments
 (0)