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.

How to Learn Nix

150 pointsby brendanfalkabout 3 years ago

21 comments

benreesmanabout 3 years ago
Nix is advanced alien technology that was badly damaged when it fell from the sky. In particular the docs&#x2F;blogs&#x2F;forums are <i>net negative</i> some ridiculously high amount of the time, like start composing an email: “I have a very special set of skills, and I will find you…” amount of the time.<p>But once it starts working: how does anyone do this any other way?<p>- The language is reasonably well-documented and those docs are rarely wrong.<p>- Learn bash, like really really learn bash.<p>- Check out nixpkgs and use that to figure out how to do stuff.<p>- Only do this if paying the entire cost in time and frustration in one aneurism-inducing spasm upfront is a worthwhile tradeoff for having everything work perfectly every time thereafter.<p>It’s kinda like being Paul Atriedes: you get magic powers but first you put your hand in the fucking box. What’s in the box?<p>“Nix!”
评论 #30684669 未加载
michael_j_wardabout 3 years ago
I spent like ~6 hours going through the first ~10 chapters of &quot;how to learn nix&quot; and the corresponding docs, and I&#x27;ve built up a decent model of how nix works under the hood but have no knowledge of how to do the things I want to do (reproducible dev environment per project)<p>Hopefully that&#x27;ll come in the next ~10 hours, or maybe I need to switch to one of these other learning resources<p>- Tutorial motivated by accomplishing things [0]<p>- Learn nix language syntax [1]<p>- If video is more your thing [2]<p>- The official &quot;bite-sized guide&quot; Nix Pills [3]<p>[0] <a href="https:&#x2F;&#x2F;nix.dev&#x2F;" rel="nofollow">https:&#x2F;&#x2F;nix.dev&#x2F;</a><p>[1] <a href="https:&#x2F;&#x2F;nixcloud.io&#x2F;tour" rel="nofollow">https:&#x2F;&#x2F;nixcloud.io&#x2F;tour</a><p>[2] <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;playlist?list=PLRGI9KQ3_HP_OFRG6R-p4iFgMSK1t5BHs" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;playlist?list=PLRGI9KQ3_HP_OFRG6R-p4...</a><p>[3] <a href="https:&#x2F;&#x2F;nixos.org&#x2F;guides&#x2F;nix-pills&#x2F;#nix-pills" rel="nofollow">https:&#x2F;&#x2F;nixos.org&#x2F;guides&#x2F;nix-pills&#x2F;#nix-pills</a>
评论 #30690553 未加载
benreesmanabout 3 years ago
I think it&#x27;s really important to have realistic expectations about Nix&#x2F;NixOS when deciding how much effort to spend on it.<p>It&#x27;s <i>ridiculously</i> hard to get started. The online resources are simply inadequate: incorrect and&#x2F;or out-of-date information is basically equally common as useful information. There isn&#x27;t a good book you can get on Amazon. The &quot;Learn&quot; boards thing is full of &quot;you&#x27;re doing it wrong&quot; bullshit. The Discord is so-so at best for getting help.<p>For me personally it was somewhere between 1-3 months of being frustrated basically every day and I still want to throw things sometimes. It&#x27;s basically clone `nixpkgs`, figure out how to get the REPL going, painstakingly reading the code of the stuff that does work, and pain.<p>It says absolutely nothing about how smart&#x2F;capable&#x2F;motivated&#x2F;senior someone is that a week or two in it&#x27;s like &quot;fuck this&quot;.<p>The payoff is <i>outrageous</i>, but the barrier to entry is nowhere near something that can be called &quot;acceptable&quot;, let alone &quot;batteries included&quot;. I completely understand why a lot of people are all-but-hostile to it.<p>I would budget a minimum of a <i>highly</i> frustrating month working with it every day to start to having the lightbulb moments, and frankly your use case needs to be pretty extreme in one way or another for that to be worth it. A lot of people don&#x27;t have a friggin month to screw around with a fairly niche infrastructure if what they&#x27;re doing now works for them.<p>I really, really hope that at some point someone gets serious about making this fairly magical thing even remotely learnable, but right now it&#x27;s a fucking mess.
评论 #30686573 未加载
评论 #30725482 未加载
alduin32about 3 years ago
I&#x27;ve found the Nix language to be a really useful configuration language, even &quot;outside&quot; of the NixOS ecosystem. I reuse nixpkgs&#x27;s module system, but to describe things that are used outside of the NixOS system (for example in an Ansible playbook).<p>For example, I&#x27;m using it to describe a set of containers and services in my infrastructure, and it allows me to properly describe the interfaces between the different components of the infrastructure, using several modules : - a &quot;base&quot; module defines the options used for describing the services - one defines the services themselves - one handles the reverse proxy configuration for these services (for multiple frontends), as well as the SSL certificates and DNS zones - one handles the containers themselves (through Docker or LXD) - one handles the networking overlay - one handles the &quot;shared services&quot; (databases, caches, etc)<p>Each of these modules is basically a function that takes the resulting configuration as argument, allowing it to reuse values defined by the other modules, and the configuration itself is the fixpoint of the composition of all of these functions.<p>It all composes quite well, and the nixpkgs module system allows me to document the options provided by each module. I can even reuse some of the existing NixOS to create a web interface where other admins can search for configuration options and lookup their documentation. Some things are exported in JSON, some are used directly as NixOS modules, some things source the inventory for Ansible playbooks, etc.<p>It allowed me to create a well-defined source of truth for a very heteregenous architecture, while preserving some of the existing workflows and tooling.<p>It&#x27;s not ideal of course : Nix itself is not typed, the nixpkgs module system provides some typing, but the integration is not perfect, and this makes error handling quite tedious. Also, the interpreter is quite slow, there is no documented way to embed it into your own program, and I
BoardsOfCanadaabout 3 years ago
I&#x27;ve tried for a couple of days now to set up nix for reproducible iOS builds at work and I&#x27;m close to tears.<p>- Examples that just don&#x27;t work.<p>- Commands that run and no output is given, even though the text I&#x27;m following says it should output information I need.<p>- Do I need nix-darwin? Well, the readme explains what it is: &quot;Nix modules for darwin, &#x2F;etc&#x2F;nixos&#x2F;configuration.nix for macOS.&quot; What? (Finally I found an answer at Stack overflow, and it seems I don&#x27;t need it. Seems to be kind of NixOS on top of macOS)<p>- Can&#x27;t build with nix-build. After long time searching it seems like you&#x27;re supposed to run nix-build -E &#x27;with import &lt;nixpkgs&gt; {}; callPackage .&#x2F;default.nix {}&#x27; - shouldn&#x27;t there be a simpler way for this common case?<p>- An issue open since 2018 that the manuals simple example doesn&#x27;t build: <a href="https:&#x2F;&#x2F;github.com&#x2F;NixOS&#x2F;nix&#x2F;issues&#x2F;2259" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;NixOS&#x2F;nix&#x2F;issues&#x2F;2259</a> People chiming in years later that they only could build the example after reading the suggestions in that issue.<p>- And now I can&#x27;t start my nix-shell because it says there&#x27;s a problem with SSL certificates. I&#x27;m giving up.
评论 #30684160 未加载
评论 #30684162 未加载
评论 #30687008 未加载
评论 #30727046 未加载
shantnutiwariabout 3 years ago
The Nix hype machine comes up on HN every few weeks.<p>As someone who tried Nix-- never understood what the big selling point is-- what can Nix do my existing tools can&#x27;t? (without me spending 6 months)<p>Nix can create isolated environments, but as far as I see, you can only install the tools Nix repo supports. And the official examples only give toy examples --here&#x27;s a simple python script you can run with Nix-- but I can just run this simple script in a virtual env, or docker if I have 2-3 different scripts.<p>What problem is Nix solving? What pain does it fix that is so important it would justify me spending 6 months on it?<p>And then there is NixOS, which again, I have no idea-- I can create my own Linux distribution that is what, reproducible? Again, is this a real problem anyone faces (and that isnt fixed by docker or ansible or any of the other hundreds of tools)?<p>My point is: Why is Nix getting so much hype when I dont see them solving any real problems? Sure, they promise a lot, but I have yet to see any real solutions.<p>Hence the Nix Hype Machine
评论 #30683684 未加载
评论 #30683670 未加载
评论 #30684146 未加载
评论 #30683725 未加载
评论 #30683778 未加载
评论 #30683820 未加载
评论 #30685687 未加载
评论 #30693932 未加载
评论 #30683808 未加载
评论 #30688448 未加载
评论 #30683582 未加载
yewenjieabout 3 years ago
My two-cents for learing Nix:<p>0. Give up the expectation of figuring it out quick<p>1. Read the official manual instead of tutorials<p>2. Read example configurations from public repos
评论 #30682868 未加载
评论 #30682637 未加载
评论 #30682404 未加载
评论 #30682506 未加载
notemakerabout 3 years ago
Something that&#x27;s helped me a lot recently (after ~9 months of using nixos) is to actively look in nixpkgs to see what options a package exposes.<p>For example, determining if and how your desktop environment can enable Wayland support.
nixpulvisabout 3 years ago
Also read: <a href="https:&#x2F;&#x2F;ianthehenry.com&#x2F;posts&#x2F;how-to-learn-nix&#x2F;ambiguous-packages" rel="nofollow">https:&#x2F;&#x2F;ianthehenry.com&#x2F;posts&#x2F;how-to-learn-nix&#x2F;ambiguous-pac...</a> for what is in my opinion one of the most damning issues with Nix.<p>Written by the same author if you didn&#x27;t notice. In fact, reading over ianthehenry&#x27;s blog is an interesting adventure in one mans experience learning this new tool.
评论 #30687942 未加载
seqizzabout 3 years ago
I&#x27;m using nixos for years, still couldn&#x27;t grasp the language itself enough. I accepted that it&#x27;s not for us, who are not familiar with functional programming. Like, what is even this: <a href="https:&#x2F;&#x2F;github.com&#x2F;Ryunaq&#x2F;dotfiles&#x2F;blob&#x2F;b132f79e2042d6ef75008d666ba12306ad21d427&#x2F;flake.nix#L60-L66" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Ryunaq&#x2F;dotfiles&#x2F;blob&#x2F;b132f79e2042d6ef7500...</a>
评论 #30684313 未加载
评论 #30684275 未加载
pmarreckabout 3 years ago
<a href="https:&#x2F;&#x2F;grahamc.com&#x2F;blog&#x2F;erase-your-darlings" rel="nofollow">https:&#x2F;&#x2F;grahamc.com&#x2F;blog&#x2F;erase-your-darlings</a> did a pretty good Nix (and ZFS) sell.<p>Of course, it was written by a guy who actually works on NixOS...
bluefirebrandabout 3 years ago
My only experience with Nix was one job, where we hired a new guy who had just done his PHD in Computer Science but never written production code.<p>Someone on the team was mentioning that our build&#x2F;deploy pipeline was a pain in the butt, and it would really be nice to have a proper CI process implemented.<p>PHD spoke up saying he could help with that, and then spent the next three months wrestling with Nix. I left the company before I saw how long it actually took him, though.<p>I saw enough to realize it would likely never be worth my time to use. Sorry Nix.
jibbitabout 3 years ago
Really enjoyed this and feel like this could be an excellent format for learning all kinds of things. I really hope it pushes on to the logical conclusion. Asking a lot, I know.
yoyohello13about 3 years ago
I see the appeal of Nix, but if your package manager requires a 50 part how-to learn series...<p>At this point I don&#x27;t really know if the juice is worth the squeeze.
评论 #30686362 未加载
timwisabout 3 years ago
Love the idea of a blog post like this. I tried something very similar a couple weeks ago on a c++ project, both in hopes it might lead to an improved user experience, and also for others struggling to figure it out.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;valhalla&#x2F;valhalla&#x2F;discussions&#x2F;3540" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;valhalla&#x2F;valhalla&#x2F;discussions&#x2F;3540</a>
pmarreckabout 3 years ago
Perfectly timed as I literally JUST started my (second ever?) Nixos attempt
account-5about 3 years ago
Novice here.<p>Can someone explain to me why I&#x27;d use this over say docker, ansible, or even a make file?<p>BTW I&#x27;m no expert in any of the aforementioned, I&#x27;ve had to use docker, was thinking of learning about make files, and wanted to look at ansible, maybe.
评论 #30684143 未加载
评论 #30687204 未加载
评论 #30684218 未加载
mcbuilderabout 3 years ago
Reading this was a bit maddening at times, because, for instance, the author always seemed to give up after 15 seconds of a command executing with not much explanation. A bit meandering.
评论 #30684048 未加载
评论 #30683488 未加载
3npabout 3 years ago
(2021)<p>Previously:<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=29303641" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=29303641</a>
mamoriamohitabout 3 years ago
&gt; Or you just memorize the “right way to do it,” and every time you type it, a part of you wonders why, until eventually your mind crystallizes around this idea that Nix is confusing and weird and too hard for you to figure out.<p>This stands true for most of the things in universe for most of the people.
yoloyoloyoloaabout 3 years ago
Ive tortured myself with Gentoo enough thank you.
评论 #30682337 未加载