NixOS: Declaring the Future of Linux❄

Discovering NixOS: A Tale of Tech Oversight.

Every now and then you come across some technology, hardware or software that’s been around, but you never really heard of or looked at. And when you do, you cannot believe why? How is this not more widespread or used. For me this was NixOS. There is much to talk about NixOS but for now the story of how I got there. 

The IT Pro’s Hidden Gem Among Linux Variants.

NixOS is a Linux distribution, there are many distributions, but this one is very different as it’s not really a distribution like any of the other main line ones. I will explain more later on. Anyone working in IT infrastructure will have heard of RedHat (RHEL), Debian, Oracle Linux or Ubuntu. Maybe you have heard of some of the more unique ones like Biebian (Justin Bieber themed), Hannah Montana Linux or Artix Linux. I started learning and working with Linux over 20 years ago, my first distribution was Debian. I used it off and on over the years, and for professional use I had to use RHEL and all derivatives so over the years I encountered many variations.  

Where We’re Going, We Don’t Need Version Conflicts.

If you have ever used any Linux version you must have come across some variation or all of these common problems like, dependency hell, version conflicts or updates breaking something and no real way to revert back, other than backups or start over or try and hack it together yourself. Now in a professional setting you might have test environments and tools and (vendor) support helping you prevent or mitigate these common issues. But what about your home lab, your laptop, your desktop or other devices you only have one single instance of running? Yeah, you break, you fix it. What if I tell you, you can have a time machine, and don’t have to break anything? 

System Configuration at 88 MPH. 

NixOS is more than just another Linux distribution; it’s a trifecta often collectively termed ‘Nix.’ Firstly, Nix is a package manager, similar to pacman, apt, dnf, or yum, but with a unique approach to dependency management. Secondly, Nix is a programming language specifically designed for describing how to build software packages or derivations. These derivations are essentially recipes that detail how to transform source files into new files, packages, or even entire software environments. Lastly, NixOS is the Linux operating system itself, which leverages the capabilities of both the Nix language and package manager to deliver a computing environment that’s not only highly reliable but also reproducible. This means you can define your entire system configuration in a declarative way, allowing for consistent system states across different machines or over time. So, while NixOS embodies these three components, it’s both a single entity and a set of integrated tools working together to redefine system administration. 

From Academic Flux to Community Fusion.

Where did it come from? NixOS began as a research project by Eelco Dolstra at Utrecht University. He aimed for a more reliable software distribution solution, that led to the development of the Package Manager. His work resulted in his PhD. thesis “The Purely Functional Software Deployment Model.” There were some follow up papers that showed the theoretical and practical advancements of Nix between his initial thesis and 2005. And around 2010 it gained more traction and started to get a community. In 2015 the NixOS Foundation was established, working on better documentation and more structured releases. Now NixOS has a biannual release cycle. Nixpkgs, the Nix packages ecosystem grew to the largest repository for software packages for any Linux distribution with more up to date, fresh and extensive software packages than in any Linux repository today.    

The System Almanac of States, You Yill Never Lose Again.  

Let’s discuss the time machine. The way NixOS, Nix and Nixpkgs works is that your system state is declared. When you start out you basically have 2 configuration files, one specific to your hardware and one for basically anything else. You want to edit these files to manipulate what is installed and configured on your system. For example, installed software, services that should start and much more. Every time you make changes; you have to rebuild your system. It basically starts reading your configuration file and validates it, if it’s correct, it will try and build it, once it is building your new configuration is loaded right in front of you. Most of it will be cached (from previous build) so only new files will be changed or downloaded, so it shouldn’t take too long. For every rebuild you will find a new entry in your boot sequence. This is where the time machine functionality displays itsef. What if you rebuild the system but some software packages or configurations are not working out the way you wanted; reboot and pick the previous entry, and voila you are back where you were before. There is only one timeline. 

Rebuilding My System’s Future.

So how did I discover Nix? After discussing my latest issues with my Fedora installation and some software issues I had on a Discord server. A user, name dropped “NixOS, this might be what you are looking for” …  I looked it up, read the front page of Nixos.org and passed it off. It looked like a lot of work to switch over to such a fundamentally different distribution and would it solve my problems? I switched from Fedora to Debian, in the hope I wouldn’t encounter the issues I had with Fedora but got other issues instead. Things that worked fine on Fedora didn’t work with Debian, at least not the way I wanted it. Back too Fedora it was. Then came the 15th rebuild of my system and thought, oh I might as well try NixOS now and see what it can do. At first glance I wasn’t impressed. Then I started extending my system with more software and configurations and started to understand the rebuild and roll back options. I started to use more of the advanced declarative properties, I could experiment with software and settings and truly try before I buy/commit, I was sold.  

Running On Declaration, Not Fuel. 

But there’s more to discuss. I haven’t yet delved into the reproducible and declarative aspects of NixOS. In essence, with NixOS, you define the end state of your system, not the steps to achieve it. This includes specifying software, running services, network configurations, and more. By using the same configuration files, you can ensure that you get an identical system setup every time—talk about reproducibility! You might wonder, doesn’t Ansible do the same? Not quite. The key distinction lies between declarative and imperative approaches: With NixOS, you declare how you want the system to be, rather than instructing it step-by-step how to get there. 

The Flaky Flux State.

There’s much more to uncover with Nix and NixOS, especially with features like Nix Flakes and Home Manager, which have become community staples. Nix Flakes allow for precise control over software sources and versions, essentially giving you a different timeline for your software environment. Home Manager complements this by letting you tailor both system-wide and user-specific settings, offering a personalized touch to your NixOS setup. These tools, when used together, unlock the full potential of NixOS. In upcoming articles, we’ll dive deeper into how NixOS revolutionizes package management, explore the philosophy behind declarative versus imperative system configuration, and look at practical implementations from home labs to professional environments. We’ll also trace the journey of NixOS from an academic project to a leading edge in Linux distributions and provide step-by-step guides on leveraging NixOS for consistent development environments and beyond. 

 

Tim Oudesluijs-Zelle