5 ms·
Slightly off topic, but Claude Code (and likely other models/harnesses) are incredibly effective at Nix. It can trivially self-verify, without side effects, whi
by hamandcheese 2mo ago
Slightly off topic, but Claude Code (and likely other models/harnesses) are incredibly effective at Nix. It can trivially self-verify, without side effects, which is a perfect match for an LLM.
If you've ever been put off by the difficulty of the language, it's worth checking it out again with AI assistance.
- colordrops 2mo agoI've one-shotted custom distributions built with Nix using AI. It's crazy how well AI and Nix fit together.
- Loeffelmann 2mo agoI also love how with the right system prompt they can pull in tooling for what they currently need via a nix shell
- sunaookami 2mo agoAlso incredibly useful with "comma" so Claude can directly use tools that are not installed yet or only one-off: https://github.com/nix-community/comma https://github.com/nix-community/comma
- graham33 2mo agoAgreed, Claude has helped a lot with this project, and being able to iterate without side effects for system configuration changes is really a game changer for agents.
- aomix 2mo agoI got curious one Saturday and ported our monorepo to use Nix for build and test and release. It was a very pleasant process. I had to put aside to tackle more pressing things but I'm all in on using Nix in that capacity.
- HellsMaddy 2mo agoAbsolutely. Running NixOS is a wonderful experience for this reason. NixOS + LLMs make it a breeze to make changes to your system, install and configure new software, and debug issues. Having every aspect of your system defined in a git repo is the perfect fit for agent harnesses. I'll admit, even with LLMs to help, the Nix language and NixOS did have a rather steep learning curve, because it's quite different from anything I'd experienced before. But after getting the hang of it, I can't imagine going back to a "normal" OS and I'm very happy I put in the time to get over the initial friction.
- dhon_ 2mo agoYou can also push deployments to remote systems which is great for servers and headless devices like raspberry pis. I use colmena and deploy-rs on different projects because they have some nice features but you can also do it with bare nix. I have a repo for kiosk appliances that can build an SD card image for a specific device in a fleet (so no on device configuration is required) but it can also push out updates or changes at runtime. NixOS isn't perfect for embedded devices yet but works well for cases like this in my experience.
- bergkvist 2mo agoIf you are using an Apple Silicon laptop and you want to deploy to an x86-64 Linux box, this can get a bit annoying due needing to deal with cross compilation in nix.
- graham33 2mo agoYou can have an x86-64 remote builder, or use a service like nixbuild.net, rather than use cross-compilation.
- JamesSwift 1mo agoYou can easily spin up a linux builder vm or I just have a dedicated remote builder on my network which I offload to
- diarrhea 1mo agoThe Make target I use to deploy in this manner (MacBook to x86-64, single machine) is simply: server: @echo "Deploying machine (with ssh-agent forwarding): '$(MACHINE)'" NIX_SSHOPTS="-A" \ nix run nixpkgs#nixos-rebuild -- switch \ --flake .#$(MACHINE) \ --target-host $(MACHINE).$(DOMAIN) \ --build-host $(MACHINE).$(DOMAIN) \ --no-reexec \ --verbose \ --sudo Which has been working well. I admit I do not understand what all of these flags do in detail. This uses ssh agent forwarding, and then sudo via PAM. That allows for passwordless sudo. Building (well, activating) without sudo is pretty involved last I checked, I could not get it to work.
- mbo 2mo agoSame for Bazel. It has historically been a very difficult to understand/adopt/rollout tool for a lot of engineering orgs but is going swimmingly for the organization I currently work for.
- miki123211 2mo agoAnd to add to that, LLMs start with fresh context on each conversation, so they don't have the understanding of your system that human employees do. Nix lets you naturally encode that understanding in code (and in comments), making sure it never drifts from what the state of the system really is. I never saw much point in Nix, but if you put it like that... now I want to try.
- rgoulter 2mo agoNix (& NixOS) are very much in the same "as code" as Terraform. -- You put in extra effort now, to save effort later. This isn't traditionally 'practical'. It's quicker to just install the package, compared to writing a declaration that says to make the package available. (And for ops, Docker images won out in terms of practicality). Nix also quite a steep learning curve.. I expect a beginner just wants to learn how to write a package in Nix, and not learn about 'derivations', 'instantiation', etc. Interesting to see LLM coding agents adjust that trade-off: significantly reducing the cost to "write something in Nix", so the benefits become much cheaper.
- jbstack 1mo agoIt's true that the Nix language is quite difficult to learn. However, part of that is the poor documentation, and the weird situation where flakes are the de facto modern way of doing things, but are still treated as an "experimental" feature (which leads to further confusion when reading documentation based on the old way of doing things). Luckily LLMs can help with this too. I asked ChatGPT to generate a course with just enough content to help an ordinary NixOS user configure their system, work with Nix code and flakes, and create/modify simple packages (which is rarely needed anyway). Just a few hours of that gave me a much stronger understanding than all the documentation / tutorials I had read before.
- sohrob 2mo agoI set up my homelab server running NixOS entirely using Claude and what would have likely taken me months (if not years) doing it the old fashioned way, got reduced to a few hours of back and forth iteration.
- arikrahman 2mo agoLikewise, I don't know where my dotfiles would be without deepseek/reasonix model configuring my entire OS for almust free with cache hits.
- glaslong 1mo agoThis. One of the surprising delights of coding models has been trivially reworking my homelab into proxmox and nixos. It's a very good testable, repeatable flow for LLMs.