TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Devenv.sh: Fast and reproducible developer environments using Nix

382 pointsby frankpfover 2 years ago

24 comments

domenkozarover 2 years ago
Hi all, I&#x27;m the author of <a href="https:&#x2F;&#x2F;devenv.sh" rel="nofollow">https:&#x2F;&#x2F;devenv.sh</a>, <a href="https:&#x2F;&#x2F;cachix.org" rel="nofollow">https:&#x2F;&#x2F;cachix.org</a> and <a href="https:&#x2F;&#x2F;nix.dev" rel="nofollow">https:&#x2F;&#x2F;nix.dev</a>.<p>I&#x27;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.<p>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.<p>I&#x27;m really looking forward what you build on top of devenv. We&#x27;re only beginning to explore the area of what&#x27;s possible, so please give as much feedback as you have.
评论 #33677815 未加载
评论 #33680119 未加载
评论 #33678945 未加载
评论 #33677338 未加载
评论 #33678421 未加载
评论 #33680616 未加载
评论 #33677711 未加载
评论 #33680044 未加载
评论 #33680091 未加载
评论 #33677511 未加载
colinsaneover 2 years ago
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.<p>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 competitions, if you can’t relate.<p>the environments i create for these follow similar patterns. it’s either python with numpy, pandas and plotly, or it’s Rust with clap and serde, say. i’d love a tool where i can just `cd &#x2F;tmp&#x2F;my-hourlong-project` and then `devenv python` to get a python shell that’ll have everything i often use (and probably more).<p>hearing from people who use these tools, nobody has told me that any of these can do this — except that since they crawl up the fs tree looking for their env definition maybe i could just stash some definitions at the fs root and get globally-invokable environments that way. seems hacky though: i’d hope for a method that’s more officially supported.
评论 #33676654 未加载
评论 #33677156 未加载
评论 #33679921 未加载
评论 #33676263 未加载
评论 #33676238 未加载
评论 #33678047 未加载
评论 #33676313 未加载
评论 #33680369 未加载
antoniojtorresover 2 years ago
This looks nice! I’m really enthusiastic about these nix based dev env systems. Recently saw devbox[0] here, tried it out and fell in love. It’s made me very interested in all things Nix!<p>0 - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=32600821" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=32600821</a>
评论 #33675637 未加载
cphooverover 2 years ago
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.
评论 #33675631 未加载
评论 #33677092 未加载
评论 #33675484 未加载
评论 #33675504 未加载
评论 #33679733 未加载
评论 #33678309 未加载
评论 #33675941 未加载
评论 #33676016 未加载
评论 #33679844 未加载
评论 #33675407 未加载
评论 #33675895 未加载
评论 #33675394 未加载
评论 #33675402 未加载
solaticover 2 years ago
There&#x27;s a long tail of issues that continue to plague Nix. Sometimes, not even the fault of the Nix project itself.<p>Case in point for my current employer&#x27;s Python shop - everyone runs PyCharm. Well, JetBrains doesn&#x27;t really support Nix-based environments. See e.g. <a href="https:&#x2F;&#x2F;youtrack.jetbrains.com&#x2F;issue&#x2F;PY-42461" rel="nofollow">https:&#x2F;&#x2F;youtrack.jetbrains.com&#x2F;issue&#x2F;PY-42461</a> . So basically something like this would be DOA. Is this something that someone like @domenkozar can fix? @grhmc ? I don&#x27;t know.
评论 #33690835 未加载
babyover 2 years ago
This is great! After spending some time with nix and writing <a href="https:&#x2F;&#x2F;mimoo.github.io&#x2F;nixbyexample&#x2F;" rel="nofollow">https:&#x2F;&#x2F;mimoo.github.io&#x2F;nixbyexample&#x2F;</a> I figured it’s too consuming and hard to manage nix yourself. These usable user-facing tools are really what nix needs to go to the next level
td7xover 2 years ago
Nix newbie, welcoming a lower entry - but is devenv.sh still nix? For example, is the devenv cli needed or is it extra?
selimnairbover 2 years ago
Going to ask a naive and possibly lazy question. On macOS does this replace Homebrew and MacPorts? I used to use MacPorts, now Homebrew. However, I’m thinking of switching back to MacPorts due to how painful using prior package versions is in Homebrew; sometimes I can’t run bleeding edge versions, and Homebrew’s all or nothing approach to versions isn’t working for me anymore.<p>I use Python with a few key native packages that are a pain to build myself (NumPy, GDAL primarily). Should I be considering Nix instead of MacPorts?
评论 #33680877 未加载
oxffover 2 years ago
&gt; Anything about Nix &gt; fast<p>Massive doubt.jpeg, as all my previous attempts at understanding and using Nix have all been &quot;trust me bro, THIS random github repo source code has the Current Best Practice (already outdated)&quot; and various other random two article blogs on how great nix is.
airockerover 2 years ago
I think it is an overkill to have your dev environment different from your deploy environments. This would mean you maintain dev environments separately than deploy environments. It would mean you are debugging something other than you are testing and deploying.<p>About reproducibility, unless nix promises to fix all upstreams (apt, pypi ??), I don&#x27;t see how it can fix reproducibility on the client side only.
评论 #33677755 未加载
评论 #33679179 未加载
评论 #33677505 未加载
charliermarshover 2 years ago
Another project I&#x27;ve been following in this space (no affiliation) is Tangram (<a href="https:&#x2F;&#x2F;www.tangram.dev&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.tangram.dev&#x2F;</a>), which I think of as &quot;Nix, but TypeScript&quot; -- or, from their Discord:<p>&gt; Tangram takes a lot of inspiration from nix, and could be described as a mix between nix and bazel where you write JS&#x2F;TS
评论 #33678321 未加载
Jabdoa2over 2 years ago
Is there a way to specify a specific version of a language in devenv? I checked to docs and even read the nix tutorial but could not figure this out.<p>I like to idea of having this in every repository in our codebase. Would make bootstrapping easier for new developers. However, you often want a specific golang or python version. Once you update some tool or language everybody gets the new env. That would be neat. Is that possible somehow?<p>I guess initially we would roll this out just for dev and keep Dockerfiles how they are but eventually we could then use it as builder in docker.<p>Bonus question: Can I use devenv&#x2F;nix together with Bazel? We use that in quite a few newer projects and it also suffers from the local dev env issue.
评论 #33685103 未加载
crabmusketover 2 years ago
Seems like Nix is having a bit of a moment. After devbox[1] was released I started looking into Nix, and there&#x27;s a lot happening.<p>I&#x27;m staying away from these Nix wrappers and learning how to do some basic nix-shell work, myself. Until it&#x27;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.<p>For the curious, this post[2] describes mixing Nix and Docker. And this[3] is a pretty decent tutorial on using Nix itself for this use case (consistent developer environments). Without going full NixOS, setting up a shell.nix with some OS-level environmental dependencies is a great way to dabble.<p>It seems there may be a sensible reaction away from &quot;Dockerise all the things&quot; for development at least, e.g. this blog post[4]. There are real downsides to containers for development, even though using things like `rvm`, `nvm` and `venv` were also a pain.<p>We&#x27;ve run into issues ourselves with developers starting to use the new M1 Macs - we&#x27;ve still not figured out how to make filesystem mounting fast yet. There seem to be other advantages to running more things locally, like simpler configuration of debuggers etc. (EDIT for clarity: the issues were with Docker, not Nix, hence the reference to filesystem mounting. Nix == &quot;running more things locally&quot;.)<p>But taking a broader view, while containerising apps with complicated dependencies is a win, we really don&#x27;t need to pretend that production and dev are actually identical environments. For example, only one of these environments needs a compiler. Once you acknowledge that the developer environment shouldn&#x27;t be fully identical to prod, then you can start to think about what things <i>do</i> need to be the same, what can differ, and what your actual requirements are.<p>[1]: <a href="https:&#x2F;&#x2F;www.jetpack.io&#x2F;devbox&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.jetpack.io&#x2F;devbox&#x2F;</a><p>[2]: <a href="https:&#x2F;&#x2F;ghedam.at&#x2F;15502&#x2F;speedy-development-environments-with-nix-and-docker" rel="nofollow">https:&#x2F;&#x2F;ghedam.at&#x2F;15502&#x2F;speedy-development-environments-with...</a><p>[3]: <a href="https:&#x2F;&#x2F;nix.dev&#x2F;tutorials&#x2F;declarative-and-reproducible-developer-environments#declarative-reproducible-envs" rel="nofollow">https:&#x2F;&#x2F;nix.dev&#x2F;tutorials&#x2F;declarative-and-reproducible-devel...</a><p>[4]: <a href="https:&#x2F;&#x2F;blog.testdouble.com&#x2F;posts&#x2F;2020-02-11-the-slippery-slope-of-docker-dev-environments&#x2F;" rel="nofollow">https:&#x2F;&#x2F;blog.testdouble.com&#x2F;posts&#x2F;2020-02-11-the-slippery-sl...</a>
评论 #33676315 未加载
评论 #33676001 未加载
plqover 2 years ago
We are using Gentoo Prefix [1] project to set up our development environment on linux. Containers etc. aren&#x27;t needed as long as the elf interpreter path and rpath are set up correctly when linking the executable (or with patchelf afterwards).<p>Highly recommended.<p>[1]: <a href="https:&#x2F;&#x2F;wiki.gentoo.org&#x2F;wiki&#x2F;Project:Prefix" rel="nofollow">https:&#x2F;&#x2F;wiki.gentoo.org&#x2F;wiki&#x2F;Project:Prefix</a>
nikolayover 2 years ago
Man, this took hours to set up on a 2019 MacBook Pro...
评论 #33679933 未加载
nvlnover 2 years ago
There is also devshell[1] which allows you to configure specific commands for your `env` and sits inside your flake.<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;numtide&#x2F;devshell" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;numtide&#x2F;devshell</a>
weitzjover 2 years ago
I still struggle to have the esp32 Cross Compiler Toolchain with the esp-rust llvm Compiler fork working with Nix. Everything without the Esp32 rust Compiler is already in nix pkg.<p>Also when trying to adopt nix for the enterprise it is still a tough barrier. At least for me struggling how to package something like the synology active backup client nix or how to setup your cups printers in nixos.<p>Besides that I hope for nix to get secure boot support.
1letterunixnameover 2 years ago
The only way to get reproducible environments is to have an immutable base OS with packages compiled without environment, library, or fs leaks. In the real world, this requires lots of patching and isolation (hypervisor and&#x2F;or containers).<p>Unfortunately, Nix suffers the fate of Haskell: so powerful that the masses can&#x27;t and don&#x27;t use it. By contrast, Homebrew spreads like cancer. &quot;Worse is better&quot;.
评论 #33679027 未加载
grudg3over 2 years ago
This looks interesting but it seems that if you&#x27;re wanting to use specific versions of two separate packages, that are not in the same nixpkgs commit, you&#x27;re a bit out of luck. For example, if I want to use an older version of Terraform with a newer version of the Terraform AzureRM provider, I couldn&#x27;t quite figure out a way to do it...
评论 #33679931 未加载
评论 #33679479 未加载
pikanixover 2 years ago
Love the experiments coming out these days: this, flox, even Replit. All working on diff approaches to a &quot;Nix UX&quot;. Someone&#x27;s going to get it right...
jbverschoorover 2 years ago
Will this create a container&#x2F;vm for your env?<p>The current state of the software supply chain makes me very uncomfortable to install any packages.
roythatappover 2 years ago
Did somebody try floxdev.com? That&#x27;s pretty much doing the job.
throwaway892238over 2 years ago
Good luck to them, but I&#x27;ll never use Nix. It&#x27;s as obscure and annoying as Gentoo (or maybe more) with no practical benefits over anything else.
评论 #33677386 未加载
评论 #33678248 未加载
stefanhaover 2 years ago
I avoid &quot;developer environments&quot; because they are different from production environments and that leads to bugs that don&#x27;t show until the application is in production. &quot;But it worked in development&quot; problems waste a lot of time.<p>Putting &quot;developer environment&quot; in the name of this tool perpetuates bad practices.<p>Any tool that constructs environments for applications should be general enough to handle both production and development.
评论 #33675866 未加载
评论 #33675912 未加载
评论 #33677788 未加载
评论 #33678240 未加载
评论 #33675972 未加载