Hacker News new | ask | show | jobs
by quchen 83 days ago
The idea is so good it’s as close to platonic as it gets. The user experience of writing your own nix expressions is so bad that it makes me angry every time I try. Not only that, but at some point the beginner help (!) meta became »use flakes, don’t do what the existing tutorials tell you, yes flakes are unstable beta and there are no tutorials but use it I beg you«. No, please, let me choose my own way to learn!

I haven’t given it a shot in the LLM age yet though, and trying out NixOS in a VM is not only easy, it is practical – in the sense that when you’re happy, you can simply boot that same config/OS anywhere else by just installing that config. And I’ll never forget that one time where I completely borked my everything in the VM, did a kernel rollback with like 3 command line args and a reboot, and the OS was, well, rolled back. As I said, almost platonic.

What I can recommend is using nix-the-package-manager. Whenever I need the newest version of something, `nix-env -i <whatever>` and it’s there and works. If it doesn’t, roll back. If I need a different version, that’s on nixpkgs as well, with the same negligible amount of friction.

6 comments

I'm not sure if I live in some kind of parallel world, because I never had any problems grokking Nix or NixOS. I started with this book[0] and haven't ever really been confused.

[0]: https://nixos-and-flakes.thiscute.world

Flakes are de facto standard at this point. Expressions are easy once you get used to them - in fact the Nix language grows on many of us, including myself, once you internalize it.

Using AI to generate Nix config is a superpower. Because the entire system is declared in a single set of config, you can basically spell cast any system you want. I one-shotted a Linux distro with custom branding for boot, installation screen, and login screen, and VPN and dev tools installed and configured by default, at a fortune 500 tech company.

>I haven’t given it a shot in the LLM age

I haven't tried it in almost a year, but using Claude Code for setting up my nix config back then worked amazingly well. I've only dabbled in NixOS, and I'm very tempted to it for my workstation when I reinstall it in the next month.

Given how much Claude Code + Opus have improved in the last year, I'd give it a fighting chance to make a nice Nix config. I'll probably start setting up a spare laptop to get the base configs dialed in before switching over to it.

To close the loop, I set up a new nixos machine, and have been using Claude Code today to work on configuring it. I was able to point it at some attempts I made in the past, ask it to modernize the setup using flakes, ask it to install a bunch of software and make a bunch of setup changes, shell setup and aliases, switch over to using sway, etc.

I've been bouncing around different vim setups for a while (lunar, astro), but they all seem needlessly complex. I do have a working astro setup, but I had a lot of problem in the past trying to apply it on Nix. Plus, I'm a fairly minimal vimer in general, so I've always felt like I might be better off doing a simpler setup.

I asked claude code to set up a minimal but modern vim config, but with: treesitter and LSPs (for python, ansible, bash, json, yml), and then adding a few other little quality of life features that I've come to rely on. It did a pretty good job, from the basic testing I've done with it so far.

It feels much more manageable than something like Astro or Lunar vims. Every time I have to upgrade those, it's a bunch of files with variables I can configure to control, but those settings aren't super well documented. The nix setup I've got is almost 700 lines in a "neovim.nix", but everything about it is configured directly in there, which seems a lot more discoverable. Fewer levels of indirection.

LLMs are a real gamechanger for Nix, highly recommend giving it a go again.
Flakes are the defacto standard and you're leaving one huge point out. Flake files come with flake lock files. You cannot get lockfiles without using flakes.
Obligatory Guix plug. I've found it way easier to understand, but it has teething issues that NixOS doesn't (latest for me was a few problems with DMs). And according to an acquaintance of mine, it works reasonably well with an LLM.