Live data from Hacker News

Devenv.sh: Fast and reproducible developer environments using Nix

devenv.sh

31–40 of 171 posts

Re: Devenv.sh: Fast and reproducible developer environments using Nix

#31

this, devbox, and others seem to be alternatives to `nix-env shell` or the flake-based `nix develop`. spurred i think by a desire for better UX. these are excellent for any project off-the-ground enough that you’ve run `git init` or created a repo. the adjacent area i’m struggling with is the “i want to write a tiny program to verify some conjecture, and i’ll probably throw it away an hour from now”. think codegolf c…

I'm not sure I understand why your suggestion is not applicable? Just keep it at the top of your temp projects and make new temporary directories once inside.

Or you could write an alias to do:

    mkdir tmp/project && cd tmp/project
    cp ~/stuff/scratchbox.nix .
     scratchbox.nix
You could even use sym/hard links if you wanted to keep the env file up to date.

Re: Devenv.sh: Fast and reproducible developer environments using Nix

#32

this, devbox, and others seem to be alternatives to `nix-env shell` or the flake-based `nix develop`. spurred i think by a desire for better UX. these are excellent for any project off-the-ground enough that you’ve run `git init` or created a repo. the adjacent area i’m struggling with is the “i want to write a tiny program to verify some conjecture, and i’ll probably throw it away an hour from now”. think codegolf c…

For python specifically, I've found my base anaconda environment to be plenty powerful enough! Sure, it's slow to install packages and create new environments, but anything I'm hacking away on for an hour will probably not be using some crazy specific pip library that I don't already have (at least not the way I prefer to write such projects it won't)

Re: Devenv.sh: Fast and reproducible developer environments using Nix

#33

Seems like Nix is having a bit of a moment. After devbox[1] was released I started looking into Nix, and there's a lot happening. I'm staying away from these Nix wrappers and learning how to do some basic nix-shell work, myself. Until it's proven the wrappers are adding real value, not just trying to hide scary scary Nix from devs who only feel safe in YAML files. For the curious, this post[2] describes mixing Nix an…

For a long time I tried to do the same and avoid 3rd party tooling. Sadly with Nix (the library, cli commands and tooling) being a moving target and having quite a few edges these wrappers are a breath of fresh air.

It'll really be wonderful once Nix gains some popularity and some of these kinks get ironed out.

Re: Devenv.sh: Fast and reproducible developer environments using Nix

#34
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.

Re: Devenv.sh: Fast and reproducible developer environments using Nix

#35

this, devbox, and others seem to be alternatives to `nix-env shell` or the flake-based `nix develop`. spurred i think by a desire for better UX. these are excellent for any project off-the-ground enough that you’ve run `git init` or created a repo. the adjacent area i’m struggling with is the “i want to write a tiny program to verify some conjecture, and i’ll probably throw it away an hour from now”. think codegolf c…

Nix flakes have a template concept where you can create a boilerplate nix flakes environment including shells, etc. You can make your own for each language environment you need and then use them to create a flake config in a folder that's ready to go with the shells you need: https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3... and https://peppe.rs/posts/novice_nix:_flake_templates/

Re: Devenv.sh: Fast and reproducible developer environments using Nix

#37
post #2

Can someone explain to me the advantage of using Nix over containers? What do they offer that are not provided with using docker or other container platform.

One difference is that Docker containers use a separate file system isolated from the host, so you have to separately install your editor/shell in there, mount/clone your dotfiles, etc. With a Nix-based development environment, it can add/override the tools you need, but you get to keep your shell customizations, editor config, etc.

Also reproducibility; it can be achieved with containers if you save the artifact (the container image), but that's not what people do in practice, they save only the recipe (the Dockerfile), and if you execute it tomorrow, it will produce a different result than today, and it will likely not even run one year from now (due to e.g. third-party apt repos changing their url, signing keys expiring, curl|bash installers that are no longer hosted, etc.). With Nix, every run will produce the same results, and sources for everything packaged in Nixpkgs are saved by nixos.org.

Re: Devenv.sh: Fast and reproducible developer environments using Nix

#39
post #37
post #2

Can someone explain to me the advantage of using Nix over containers? What do they offer that are not provided with using docker or other container platform.

One difference is that Docker containers use a separate file system isolated from the host, so you have to separately install your editor/shell in there, mount/clone your dotfiles, etc. With a Nix-based development environment, it can add/override the tools you need, but you get to keep your shell customizations, editor config, etc. Also reproducibility; it can be achieved with containers if you save the artifact (th…

> One difference is that Docker containers use a separate file system isolated from the host, so you have to separately install your editor/shell in there, mount/clone your dotfiles, etc.

Can't you just mount a volume from your host machine? Then you can use your regular editor, and just run commands from inside the container.

Re: Devenv.sh: Fast and reproducible developer environments using Nix

#40

this, devbox, and others seem to be alternatives to `nix-env shell` or the flake-based `nix develop`. spurred i think by a desire for better UX. these are excellent for any project off-the-ground enough that you’ve run `git init` or created a repo. the adjacent area i’m struggling with is the “i want to write a tiny program to verify some conjecture, and i’ll probably throw it away an hour from now”. think codegolf c…

> I’d love a tool where i can just `cd /tmp/my-hourlong-project` and then `devenv python` to get a python shell that’ll have everything i often use (and probably more)

There's a dozen projects that do this. But it would honestly take you as much time to write a shell script to do it as use some other project to do it.

Like, seriously:

  #!/usr/bin/env sh
  set -eu
  [ "${DEBUG:-0}" = "1" ] && set -x
  MY_TEMPLATE="${MY_TEMPLATE:-$HOME/.my-template.d}"
  _cleanup () { cd ; [ -n "${tmpdir:-}" ] && rm -rf "$tmpdir" ; }
  trap _cleanup EXIT
  tmpdir="$(mktemp -d)"
  cd "$tmpdir"
  cp -a "$MY_TEMPLATE"/* "$MY_TEMPLATE"/.??* . || true
  [ -e ".init.sh" ] && . ./.init.sh
  python
Post reply on HN