Give NixOS a Shot
== *** ==

Give NixOS a Shot

Est. 6m read

I’ve been using Linux for over ten years and only in the last year did I find the distro of my dreams. In this post, I’m going to try and explain why I like NixOS and how I’m using it. If you’re anything like me, switching will be a no-brainer.

Last year, I gave Fedora a shot after losing all my data. I heard it had a reputation for being stable but within a few months I had issues with my display flickering, problems unmounting disks, and several other issues that I can only attribute to a corrupted OS. At the time, the only solution I had in mind was to reinstall the OS which is something I hate to do because it requires me to reinstall and reconfigure so many different things.

As soon as Fedora started acting weird I began plotting my escape. For the next OS, I knew I needed to start putting stock into reproducibility. I began my research with Fedora Silverblue. After reading their product page and doing some research in the Fedora forums, I was not convinced that Silverblue’s failsafes were going to be enough to prevent a corrupted system file from wreaking havoc again. Silverblue also sounded incredibly restrictive, but that’s when I remembered NixOS…

I started reading through NixOS configs from the anime pfps of GitHub and it wasn’t long before I started to see just how powerful a Nix config could be.

Unlike most other Linux distros where the setup is scattered across hundreds of files and directories, NixOS is a declarative system where your applications, desktop settings, and plenty more are tracked in git and can be completely reproduced with a single command:

$ sudo nixos-rebuild switch --flake .#my-config

Instead of copying files, NixOS mostly uses read-only symlinks to /nix/store/.... This has several advantages, my favorite is that uninstalling a package rarely leaves behind stray files. Often, in other OSes, even after uninstalling the app I can find folders filled with supporting files or configuration, etc. taking up precious disk space. This has been a non-issue since switching to NixOS.

Image
Many other operating systems seem to just keep growing

Another great thing about this approach is how modular it is. You can imagine the Nix ecosystem as 100,000+ kinds of different Lego bricks and it’s up to you and your config to assemble them. There’s a brick for Google Chrome, Emacs, TeamViewer, Steam, OBS, Wayland, Hyprland, KDE Plasma, Python, NodeJS, Elixir, your favorite npm/pip packages, and so on.

Admittedly, one downside to this approach is that if the thing you’re after isn’t in Nixpkgs, it can be challenging to install. I’ve only found one package that wasn’t in Nixpkgs and considering AdsPower didn’t work on Fedora either, I’m not deducting any points.

How I’m Using NixOS

My main “machine” is named nixos which I admit is a bad name. If you look at the config, there’s a default.nix which imports several modules. For example, modules.linux is a module I wrote that installs all of the CLI tools I’ve come to expect on Linux. If I wanted to create a config for a new “machine” I can place this modules.linux in there and expect the same CLI tools to be there too.

Once my config was exactly how I wanted it, I got an itch to see how easy it would be to setup another computer. My only options were a Raspberry Pi and a MacBook Air…

NixOS on a MacBook?

I had always wanted to try Asahi but never had a good enough reason to, this is my chance.

There’s this guide from the Nix community for installing NixOS on Apple silicon. I fed it to Claude and had it walk me through the process. The first part was very easy, just a curl | sh command. I set how much disk space NixOS should use (45%) and then was instructed to reboot into the recovery state.

Instructions

Like usual, I had to create a live USB with the NixOS installer on it. In this case, I built the ISO myself using:

nixos-apple-silicon$ nix build --extra-experimental-features 'nix-command flakes' .#installer-bootstrap -o installer -j4 -L

Because they’re using Nix flakes, it only took one command to build the NixOS ISO with Apple silicon support. I think that deserves a point.

But this next part stumped me for a full day…

I was able to boot, but there’s a step during the guide where you need to connect to the internet with iwctl. I tried everything and still couldn’t get iwctl scan to work. The only clue I had was “brcmf_cfg80211_escan_handler: invalid event data length” which sounded like a driver issue but I had no clue how to fix it.

During this downtime, I realized that my nixos config (a.k.a. my desktop config) was not suitable for my MacBook. So I quickly put together a new machine named mba that is slightly stripped down.

I then posted a GitHub issue about the situation and got the answer much faster than I expected. @zzywysm explained that I could fix the driver issue by changing 3 lines in the Nix files used to build the ISO. I’m kind of surprised this isn’t the default and that I’m the only person who has reported it.

Anyways, with the new ISO, I was feeling confident…

Building the kernel
Building the kernel took over an hour
Seeing U-Boot for the first time
This sure looks promising...
sddm lockscren
Success!

Just like that, with a single command, I’ve got my user account, desktop environment, git config, SSH keys, applications, etc. ready to go. It has never been this easy.

Final Words

I gave NixOS a shot for its stability and reproducibility. Once I got more familiar with it, I realized that a declarative and modular Linux distro is what I’ve always wanted.

Keeping a Nix config reminds me of how people keep their Emacs config. You bite the bullet and build out your configuration one time and you can use it everywhere. Some people have even used the same config for 20+ years. Seeing as I’ve battle tested NixOS for several months and have nothing bad to say, I can imagine keeping a Nix config for 20 years too.

I didn’t even scratch the surface for what NixOS has to offer but if you’re a developer, I recommend you use NixOS as your daily driver. If you’re a Linux enthusiast, you should consider it and if neither of those apply, I retract my recommendation. If you want to try before you buy, Nix has a package manager for macOS, Windows and Linux and that can be a great starting point.