NixOS and Flakes

My experiences with NixOS and Flakes after years of Ubuntu

NixOS and Flakes

I started in computers using some old operating systems (VM, Zebra PIC, Sinclair, Commodore, MSX). Eventually I wrapped around DOS, and created applications with Turbo Pascal, and later with Clipper.

I moved to Windows 3.11, became a full time Microsoft boy, programmed in Delphi and later C#. At some point I got tired of the Microsoft way to do things, and moved to Python and NodeJS on a Mac, which was nice but too expensive, and finally landed on Ubuntu, which I have been using daily for ten years as my personal machine.

For the server side I used Ubuntu too, and deployed with Ansible, which was ok. But not great. Infrastructure drifted to obsolescence, updates became messy, and I was never sure of what was deployed where.

I tried to improve. Everything got on version control, I tried OpenTofu, I tried to use the tools from AWS, but still, I was never sure of what was going on. Is everything up to date? Hopefully so. But for sure? No, I was never sure. And is there any vulnerability? Well, we have the site running, let's spend now hundreds of hours trying to be sure at least of a few things.

That had an effect in everything I work. This domain fell out of use (some update of Ghost broke something, I could not roll back, then I didn't even try to fix it). I published some projects in Github, but very quickly they started to fight each other. I tried to apply the patterns from wiser programmers than me, but either I didn't understand them, or I didn't implement them correctly, or they didn't really fly as well in real life as they say on paper. Choose your preferred answer.

At some point past year I was watching a video from Geoffrey Huntley, and he mentioned briefly that some things were simpler because he used nix ('if you know you know' he said) and I became curious.

I was using ChatGPT at the time to investigate things, and the responses were encouraging. NixOS is Linux, but instead of installing and updating things with scripts and packages, you create a file with the definition of what you want installed, on which version, and you rebuild your machine. The previous version is retained, then if something breaks you just roll back.

And Flakes allow you to have a very granular configuration, and to share it between machines, which for me is excellent, given that I use a few computers every day. I ended up with a set of files describing what is common to every machine, and what is specific for each. Every file is committed to git, and every machine updates from it. Really interesting stuff, not too difficult to understand and to put to work (having help from an LLM was an enabler for me), and the number of hours I spend creating new things compared with trying to find what is broken has gone through the roof.

I am far from an expert on them. I have it working, I understand the concepts, and I lean a lot in having an LLM hired as a consultant. I am not sure if I could maintain it alone today. But on the other hand, it allowed me to finally configure my fleet of Raspberry Pis, to cleanup the NAS I have at home, to finally deploy my Kubernetes cluster and also to stabilize every machine I use. And also took care of putting this site and others back online, which I like a lot.

NixOS and flakes, highly recommended.