Hacker News new | past | comments | ask | show | jobs | submit login
Nix Flakes: An Introduction (christine.website)
61 points by flurie on Feb 21, 2022 | hide | past | favorite | 8 comments



This was wonderfully written. As a Nix beginner, I found it super helpful and wish there was more documentation that explained the major aspects of Nix this clearly.


Author of the post here. Thank you. I've been working on my style for teaching NixOS concepts for a long time. If I ever get around to writing a book on Nix/NixOS it's going to use either this style or a refined view on this style.


If it's of any use: feel free to try it out on a Linux VM to see it's also the case, but the other day I helped a coworker set-up Nix on macOS and no daemon restart was necessary after enabling flakes.

I'd love to comment on the article other than it looking very thorough, but being a NixOS user means I'm cursed to not be able to tell what "obvious" thing you might have missed. What I can say is "congratulations on posting a beginner's course knowing full well you're cursed as well", and thanks for publishing your blog! I've found it to be a great resource multiple times.


At the moment, flakes is an evaluation-time thing (thus client-side) so no restart of nix-daemon is technically required. However, if you are upgrading from 2.3 to 2.4+ it's best to restart the daemon, otherwise other things like build log output can be messed up if you try to mix client-daemon versions.


I've been putting off learning Nix until Flakes become stable. They've come up several times as I've researched various things I would want to do with Nix, and I think waiting a little longer is right for me. I'd be interested to hear what others think about this?


I think there's low-hanging fruit in terms of what you can benefit from with Nix without having to learn too much. (Albeit, learning Nix enough to be comfortable using it for what you want may take time). -- I'd encourage giving it a try anyway.

The biggest negative difference I've felt is that the 'nix classic' way of imperatively installing a package to a profile (`nix-env -iA nixpkgs.<name>`) isn't forward-compatible with the 'nix command' equivalent(`nix profile install nixpkgs#<name>`). And the latter is only compatible with flakes. So, you can use `nix-env`, until you use `nix profile`. -- nix-env/nix profile 'discouraged' because they're prone to problems from "I forgot I did that" / "I didn't know I did that".. but, still. (e.g. home-manager uses nix-env under the hood).


I love Flakes! One thing that I bugs me though is that I could not find a satisfactory solution to have non-bash shells with custom environment variables as the default `devShell`.


The command `nix print-dev-env` prints the environment variables used, which helps.

But I think a suggested DX is to make use of direnv. e.g. the nix-direnv template: https://github.com/nix-community/nix-direnv/blob/master/temp...

I think this still leaves a gap from what `nix-shell --pure` had.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: