My Journey to NixOS: A macOS User's Perspective

I've been contemplating a switch to NixOS for my secondary machine for a few days now. As someone who's dabbled in various Linux distributions since around 2019—Arch, Fedora, Ubuntu, Debian, Raspbian, and most recently Bazzite—I was intrigued by the promises of NixOS's declarative approach to system configuration.

The Contemplation Phase

My primary machine is a Mac mini that I've been using since August 2023. Before that, I was primarily a Windows user, though I've had Apple mobile devices for years—an iPod Touch 4 around 2011-2012 and an iPad Air 2 from 2015 to 2021. So while I'm not new to the Apple ecosystem, my experience with Linux distributions has been somewhat compartmentalised to my secondary machines.

What drew me to NixOS was the concept of having my entire system configuration defined in code. As someone who appreciates clean, reproducible setups, the idea that I could rebuild my entire system from a few configuration files was immensely appealing.

First Attempt: A Bit of a Fumble

My first attempt at installing NixOS was, to put it mildly, less than successful. I followed the official installation guide, but somewhere along the way, I must have missed a crucial step. The system wouldn't boot properly, and I found myself staring at error messages that might as well have been written in hieroglyphics.

Rather than bash my head against the wall, I decided to step back, take a breather, and approach the problem with fresh eyes the next day.

Second Time's the Charm

Half a day later, I was back at it. This time, I was more methodical. I carefully followed the installation guide, paying extra attention to the hardware configuration steps. I also spent some time researching common pitfalls for new NixOS users.

The difference was night and day. The installation proceeded smoothly, and before I knew it, I was looking at a fresh GNOME desktop. But the real work was just beginning.

Configuring NixOS: A Learning Curve

NixOS's approach to system configuration is fundamentally different from what I was used to with Arch or Ubuntu. Instead of manually installing packages and editing config files scattered throughout the system, everything is centralised in a few key files.

I started by examining the auto-generated hardware-configuration.nix, which correctly identified my hardware components:

boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "sd_mod" ];
boot.kernelModules = [ "kvm-intel" ];

Next, I turned my attention to configuration.nix, where the real customisation happens. I set up my hostname ("selene"), configured networking, and specified my time zone and locale settings:

networking.hostName = "selene";
networking.networkmanager.enable = true;
time.timeZone = "Europe/London";
i18n.defaultLocale = "en_GB.UTF-8";

One of the aspects I particularly appreciated was the ability to exclude GNOME packages I didn't need:

environment.gnome.excludePackages = with pkgs; [
gnome-tour
gnome-weather
# ... and many more
];

Discovering Home Manager

The real game-changer was discovering Home Manager, which allows for user-specific configurations. I imported it into my configuration.nix:

let
home-manager = builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/release-24.11.tar.gz";
in
{
imports = [
# ...
(import "${home-manager}/nixos")
./home/ewan.nix
];
# ...
}

This allowed me to keep my system-wide configurations separate from my user-specific ones, which I stored in home/ewan.nix.

Creating a Repository

As I was figuring things out, I decided to create a Git repository to track my NixOS configuration. This would not only serve as a backup but also as documentation for my future self (or anyone else who might be interested).

I added a comprehensive README.md explaining the structure of the repository and how to use it, along with warnings that this configuration is tailored for my personal use and may require adjustments for different hardware or preferences.

Reflections

Now that I have NixOS up and running, I can say it was worth the initial struggle. The learning curve is steep, especially coming from more traditional Linux distributions, but the benefits are substantial.

The declarative approach to system configuration means I can easily reproduce my setup on another machine or recover from a system failure. It also forces me to be more intentional about the changes I make to my system.

While I still use macOS as my daily driver, NixOS has earned its place on my secondary machine. And who knows? Maybe one day I'll take the plunge and make it my primary OS.

For now, though, I'm enjoying the journey of discovery and the satisfaction of having a system that's configured exactly the way I want it.