Hacker News new | ask | show | jobs
by domenkozar 1311 days ago
Hi all, I'm the author of https://devenv.sh, https://cachix.org and https://nix.dev.

I've been part of the Nix community for more than 10 years and in the last 4 years focused on making it documented, simple and accessible for any developer.

After building Cachix (where you can store any software binaries with a few steps) we realized that there needs to be an intuitive interface for crafting developer environments.

I'm really looking forward what you build on top of devenv. We're only beginning to explore the area of what's possible, so please give as much feedback as you have.

8 comments

I hope this doesn't come off critical - but what does this offer over a flakes-based `devShell` with `nix develop`?

The two things that stand out that maybe look slightly easier are the processes section, and the pre-commit hooks sections - but from what I can tell these are generally all solveable via native flakes.

Just curious - if this is a valuable tool to add to the arsenal, I'm all for it, but I'm curious what the strong selling points are here over what is already available.

It depends a lot from where you are coming from. It seems like you have prior Nix experience:

The main benefit is abstraction using modules: this allows you to extend, compose and abstract your environment. Processes and pre-commit hooks are only the beginning of what's possible.

There's also higher-level CLI interface for building images, sharing environments, etc.

Note that this is only scratching the design surface of what's possible.

This I wonder too. I have not yet dived into this part of the nix ecosystem so I can't tell the differences but it looks superficially similar. It would be good if the main differences could be explained.
How do things that aren't NixOS packages interact with this? E.g. if I want a Python package that I can install with pip, or acquire in some other way, that isn't in NixOS's packages.
Looks great, looking forward to trying it out.

I've been mentioning to a work colleague that someone needs to do for the somewhat baroque Nix tools and concepts what Docker did for containers.

It just needs a nice porcelain over the top that provides some consistent CLI UX, but lets you dive down deeper as you get more comfortable with the system.

As someone who just two weeks ago got into Nix/NixOS via this repo[1] from mitchellh, one thing I'd love:

A nice, seamless way to remote connect JetBrains IDEs or VS Code into the environment.

I tried the VS Code server, but had some problems getting it going on ARM Linux (my machine is an M1 Mac, and I'm running nixOS inside an arm64 VM).

I have been surviving on NeoVIM, but really would like to use the editors/IDEs I am used to.

Something like starting up the JetBrains Fleet/Gateway kind of thing, or VS Code server, when entering an env, so that I can connect the IDE to the environment, and it has access to everything in that environment.

Since I don't see me convincing the 20+ people in my team to switch to VIM :)

[1] https://github.com/mitchellh/nixos-config

I've been hacking on VSCode integration as of yesterday, follow https://github.com/cachix/devenv/issues/26 for updates :)

This shouldn't be more than a day of work.

Do you use NixOS? I've found it a little too clunky for my taste, as a Gentoo Linux user. But maybe Nix is still worthwhile for me as a standalone tool.
I used to be a Gentoo user until about 2013: https://domenkozar.com/2013/07/20/9-years-of-linux-distribut...
Can you elaborate on what about it is clunky?

I've used it as my daily driver for the past year so maybe I can help elaborate too.

I felt like I could never find the docs for what I wanted to do. I had a constant feeling that I was doing stupid stuff that's not considered best practices. I've also tried to use it to manage my home dir with some third party tool recommended by the community, but it felt very hacksish compared to the rest of NixOS.
I used Gentoo for over 15 years before switching to NixOS. I like it so much better, I'm never going back.
How about someone from let's say Ubuntu/Debian or Fedora?
Coming originally from Fedora, anything non-declarative (like NixOS or Guix) feels incredibly clunky for servers. There is an incredible value in writing a server configuration once that is fully reproducible and results in systems that don't have drift.

For desktops there is that value as well. However, I have usually set up my macOS environment in two hours or so, the pay-off is a bit less for me. However, setting up a dev environment for development projects is awesome, especially if a project has dependencies that are normally considered system dependencies (e.g. native libraries).

I used Ubuntu for 8 years and switched about 10 months ago and never going back. Ubuntu feels primitive like VAX or TRS80 in comparison.
I ran Gentoo for a few years, but the distros I used most in the years immediately before discovering NixOS were (based on) openSUSE, Arch, and Ubuntu.

NixOS is more similar, culturally (rather than technically), to Debian than it is to Ubuntu or Fedora, both in the sense that it's not backed by a large corporation and also in the sense that it doesn't promote a particular vision of the Linux desktop.

On a technical level, its package management approach will feel like a larger paradigmatic leap, coming from a Fedora or an Ubuntu, than it would from a Gentoo. NixOS doesn't have quite the same notion of a repository as either of the former. The concept of 'overlays', used to extend Nixpkgs, would be familiar to a Gentoo user but not a Fedora user.

That said, an Ubuntu user won't notice a lot of compilation from source, and in fact they'll likely find Nix pretty fast as a package manager. And likewise, NixOS is more different from any of those than it is similar to Gentoo.

An Ubuntu user switching to NixOS will likely be

  - impressed with the wide selection of packages
  - happy with how easy it is to iterate on a config
  - delighted by the rollbacks
  - pleased with how easy it is to add most software to Nixpkgs
  - eventually frustrated by the inflexibility of having to package things for Nix to get them to work well on NixOS
  - appreciative that their system doesn't accrue cruft over time
  - perplexed with having to learn slightly different processes for packaging things in different language ecosystems in Nixpkgs
  - blown away by the knowledgeable and helpful community
depending on how deep they go with NixOS. Overall, I can't say if you'll like the whole declarative paradigm or not, which will be the biggest difference. But bear in mind that you can enjoy many of the benefits of Nix while still keeping one foot 'in both worlds', by using Nix on top of Ubuntu or Fedora rather than jumping in with NixOS.

Jumping right in with NixOS is a good idea if

  - your needs are simple, or
  - you have a bit of packaging experience (for any distro), or
  - you have an interest in functional programming, or
  - you like learning new things, or
  - the reproducibility and uniform management of your system's configuration is highly appealing to you.
If you have less Linux experience, or you feel less inclined to commit to the whole paradigm for any reason, try giving yourself a taste of Nix and NixOS' declarative style by running Nix and Home Manager on top of your existing distro of choice! I think NixOS is in a mature enough state that there's just a ton of functionality and packages in it, and lots of Linux users could be happy with it as-is. But for those who are thinking about getting into extending it and molding it to fit their own needs but aren't sure about the hairy details of that kind of work, running Nix on foreign Linux can be a good, noncommittal way to get a sense of what that work looks like.

On the whole, I think any experienced Linux user will at least find it interesting. But the more common response from those who really get a handle of it is 'I could never go back'.

Thank you for the write-up!
The nix language basics section of nix.dev finally got me to understand what is actually going on in a derivation file and in my default.nix, so thank you!
You're welcome, that tutorial was written by https://github.com/fricklerhandwerk
Do you have a story for how this works with CI? I have a few projects that use a shell.nix to provide my dev environment, then in CI I just do:

    image: nixos/nix:latest

    before_script:
      - nix-env -f shell.nix -i -A buildInputs
This then gives me a CI environment that perfectly matches my dev environment at all times. Some similar story for devenv would be great.

Of course I'm not sure how that would work - one of the things that interests me with devenv over 'vanilla' nix is your approach to processes which doesn't map so well in the scenario I've described.

You can see how it's used in the GitHub actions of devenv:

It calls `devenv ci` (which checks that the devenv file is good), then runs a 'script' in the devenv file... https://github.com/cachix/devenv/blob/8bea91cd1073b0d51cf96e...

The 'script' in the devenv file: https://github.com/cachix/devenv/blob/8bea91cd1073b0d51cf96e...

Love the direction you're taking this :) as without reproducibility we have nothing..
Does devenv uses flakes underneath?

Also, it's called devenv.sh, but.. is it written in shell script?