Lurker News
Devbox is a command-line tool that lets you easily create isolated shells and containers. 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.

In practice, Devbox works similar 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).
See it in action: https://youtu.be/WMBaXQZmDoA

Comments (185) 47 threads

jitl6 replies#
Looks really good. A layer over Nix that makes it tolerable sounds like a godsend. I’ve had a TODO item for “somehow use Nix for our dev env” at Notion since 2019, but I keep kicking the can down the road because its better to tolerate a 500 line setup script than learn all the Nix stuff. Of course we could use Docker, but then on Mac our dev process would be 3x slower.

Congrats to Daniel and the team! Excited to see what’s next after this.

xvector4 replies#
Nix absolutely needed a wrapper like this to be used 'in the real world.'

When you think about bringing it to production (eg getting dev teams to migrate to it), Nix goes from a genuinely interesting idea to an "oh, that's cute" experimental toy because no one is going to spend hours learning Nix's weird DSL. It's simply not approachable in its base form.
I spent hours converting my devboxes to NixOS and managing my dev environments with home-manager and I still don't have a clue how any of it works. Errors are opaque and annoying to debug. Dev environments constantly break and change in ways that belay the "reproducible" nature of Nix. If someone actively interested in Nix can't easily grasp it, how does anyone expect it to catch on in the real world?

mrich1 reply#
When there are issues with debugging breakages of such environments, will a wrapper be sufficient? Does devbox have extra handling for such scenarios?
pxc#
The opacity of Nix errors is largely (entirely?) constrained to the module systems (notably NixOS, Nix-Darwin, and Home Manager). (This is unfortunate, because these are actually some of the best parts of the Nix ecosystem.)

The issue is essentially that configuration options all get merged into a global namespace, but there are no facilities to track where they came from. So when configuration mismatches of certain kinds occur, you get an error in some library code that's trying to merge or coerce two incompatible values, and nothing pointing you to the two places where the conflicting values are originally set.
(This kind of error, the most common mostly-useless error message, is typically easily debugged by searching for the relevant options in your configuration and in the source code of that collection of modules. But that is still backwards and a chore, and deserves a real solution.)
Anyway, the package definitions and builds in Nixpkgs don't use any such module system in any way. So this tool is not wrapping the functionality that is associated with opaque error messages. :)

baby2 replies#
My theory is that we need better learning resources (that’s why I’m working on https://mimoo.github.io/nixbyexample/), better tooling (debugging or starting a project from scratch is hard), better integration with rust/js/etc. projects based on convention (and not configuration: I shouldn’t have to point to more than a Cargo.toml or package.json and nix should do the rest)
gamjQZnHT53AMa1 reply#
This looks great. As someone who started learning Nix in the last few weeks this is definitely needed and will prove invaluable to future learners. I'm still completely lost on a lot of things but if I work something out that isn't covered on your site I'll try and put together a PR for it.

Continue this thread — 1 reply

unicornmama1 reply#
The problem is boundless complexity. Learning resources won’t help anyone to learn and manage boundless complexity.

Continue this thread — 1 reply

otabdeveloper41 reply#
I think you're confusing Nix, nixpkgs and NixOs.

(Also Nix and Nix-flakes are two different things, like Javascript and React.)

nitsky2 replies#
I think this attempt at clarification is just proving xvector’s point.

Continue this thread — 2 replies

ParetoOptimal#
> Nix goes from a genuinely interesting idea to an "oh, that's cute" experimental toy because no one is going to spend hours learning Nix's weird DSL. It's simply not approachable in its base form.

Here's an opposite opinion:
> My hot take is that Nix actually has great syntax
> In particular, the way Nix handles record syntax is exemplary and more languages should copy what Nix does in this regard
And even more related to this discussion:
> A lot of the times, when people say they hate "Nix's syntax", what they more likely mean is that they hate the domain-specific languages of the Nixpkgs overlay system and/or the NixOS module system
https://mobile.twitter.com/GabriellaG439/status/156300116656...

nidnogg2 replies#
>Of course we could use Docker, but then on Mac our dev process would be 3x slower.

Doesn't devbox depend on Docker, though? I figure any performance losses from Docker would happen with this too.

Aeolun#
Only for the build step (e.g. making a docker image). The dev step runs entirely on your machine.

I got that from the README btw, no guarantees :)

dloreto2 replies#
The dependency on Docker only exists for when you want to turn your shell into a container – but it's not otherwise used when you're just running a shell locally.

When writing javascript there's often a desire to have "isomorphic" or "universal" applications. Write the code once and run it in _either_ the client or the _server_.
Devbox is taking a similar approach to the development environment: declare it once, run it locally as a shell, and when you're ready, turn it into a container without having to re-declare it. It's only the latter functionality that has a Docker dependency.

nidnogg#
Hmmm, I'll be keeping an eye on this one then!
chupasaurus#
It's actually not since BuildKit could be run as a standalone daemon, and you can run the result via containerd which is a dependency of Docker. Might write a PR over the weekend(s).
idontwantthis3 replies#
I just set up a docker dev environment on Mac and I would not call it slow anymore. If you were referring to volume mounts, they are 10x faster now. Definitely fast enough for our work.
baby#
Depends how much memory your container needs to build…
greymalik1 reply#
> they are 10x faster now

What changed?

porker#
Virtiofs
ParetoOptimal#
> they are 10x faster now. Definitely fast enough for our work.

They are definitely faster and great improvements.
But when I can use Linux through qemu and compile my companies Haskell application in 45s rather than 3m30s...
The choice is obvious to use Linux.

mhio2 replies#
> Of course we could use Docker, but then on Mac our dev process would be 3x slower

Out of interest, what in your dev process makes using containers so impactful?

TheCapeGreek1 reply#
Docker on Mac and Windows runs in a VM, not natively.
mhio#
3x slower is not regular VM overhead range.

Using the dodgy file share volume mounting, maybe for particular file access patterns.

lozenge#
They probably want their source code on their "real" filesystem which makes Docker painfully slow.
ianpurton#
> Of course we could use Docker, but then on Mac our dev process would be 3x slower.

Not in my experience.
If you set up volumes for node_modules or any folders where where dependencies are stored you get the same performance on Mac as anywhere else.
For rust, which I use, I'm able to get better performance on Mac under docker than using rust tools natively. See https://purton.tech/blog/faster-rust-incremental-builds/

Continue this thread — 1 more reply

dloreto4 replies#
Having a deterministic environment, but that is actually running on your laptop is so much better than working inside a docker container. Inside a container the file system is very slow, and you lose all of your other tools and shell aliases.
whiddershins1 reply#
So, that’s what this is?
vhanda2 replies#
I haven't run devbox, but the README says that it requires docker to be installed. This makes me believe it isn't running the programs on my system (macos), but rather in the Linux VM.
jljljl#
It will use Nix to build a shell on your local machine directly, so you can run the program on your system directly (not in a VM).

It also has some early functionality where you can turn that shell into a Docker container, so you can run the same shell + program in other environments or in the cloud

xlix7 replies#
so an abstration on top of docker?

Continue this thread — 7 replies

justinsaccount2 replies#
This is a cool project and yay nix, but:

> Inside a container the file system is very slow
Because you are not using "a container".
You are using a container that happens to be running in a linux VM on your OS X laptop. It's not the containers fault, it's the entire virtual machine that you are running because you're trying to run technology built on top of one operating system while running a completely different one.

endorphine2 replies#
This. Put another way: it's slow only because you're on macOS and not on Linux.
dloreto#
Totally fair.
neop1x#
That's why Linux needs more love.

I find it sad that many people use Docker, but the majority of them run Linux in a VM inside an expensive proprietary platform to do so, sometimes without even realizing it.
Meanwhile, the Linux desktop ecosystem is deteriorating and should be used more and receive more financial support.

throwaway8922382 replies#
Overlay copy-on-write filesystems are slow. I think most container runtimes use them.
baq1 reply#
compared to full-VMs-pretending-to-be-containers everything is fast.

it seems like everybody here is using Macs for development to the point that if you don't say you aren't, you are assumed to be on a mac. Windows with WSL2 is actually pleasant to use, I can recommend trying it out. while WSL2 is a VM technically, the level of integration makes it basically native (if you use the VM disk for your workspace, which you should.)

Continue this thread — 1 reply

justinsaccount#
It's not the COW filesystem that is slow, it's bind mounting the host filesystem into the VM. This ends up using something like 9p or sshfs.
nicoburns3 replies#
What I really want is a tool like docker compose that builds on top of a tool like this (instead of docker)

Continue this thread — 3 replies

Continue this thread — 1 more reply

x0rg12 replies#
This is shelling out to nix-shell (https://github.com/jetpack-io/devbox/blob/97c19c370287e203bb...) which means that it will only support bash AFAIK. I've seen a lot of discussions around using nix-shell for dev environments, but read somewhere that is not really made for this purpose originally, rather for just building packages, bash being only one of the limitations.

I tried to experiment myself with nix-shell, but I think it doesn't provide separation on the machine on which you run, it's not a chroot nor a docker container. If you are interested in some level of separation to make sure that a dev environment is "safe" to run on your machine without making side effects to things external to the project, then I'm not sure nix-shell would be able to help, but I would be happy to learn there is an option to do otherwise.

Continue this thread — 12 replies

amir-h#
Looks really nice! I'm wondering though whether this is luring me into a dangerous complexity cliff.

It seems easy to start using, but will I run into some issues a few months down the line like a package that's not available through Nix, or some Nix issue, and then I'm back to dealing with Nix's complexity only that I got there while staying clueless about Nix.

Load more comments