A year of NixOS

January 7, 2019 - Software, Nix - 11 minutes

I had been using a Macbook Pro as my development machine of choice for the past 8 years. My first was still when they had the aluminium key caps. In the beginning, I used my machine for a lot of tasks, graphics, video editing, music production, etc - but as I moved more and more into software development, my values and alignment for what I wanted out of my machine changed.

I tweeted generally about my NixOS experience the other day.

I received a number of likes and retweets unexpectedly, so I decided to write a little more about my overall experience which I hope is helpful to you.

Enter NixOS

It came across my news feed sometime in 2015. I think it had been around since 2008 according to the commit history in Github.

Pure, reproducible builds. There was something about this that alerted my intuition in the same way that Haskell did a few years earlier about how powerful an idea like this could be.

I didn’t jump into it immediately simply because NixOS (as far as I knew) wasn’t that well adopted at the time and my knowledge and experience with *nix style operating systems was woeful. I didn’t consider myself anywhere near a Linux power user.

I had used and experimented with Ubuntu and Arch Linux in the past for months at a time with them, and I really did struggle (yes, even with Ubuntu). At the time, I was primarily developing for the web so I never had spent the time dealing with OS specifics.

It wasn’t until this post on installing NixOS, that I realised that many Haskellers had already started using NixOS. Now that I had a guide and someone who had been on the journey, it was time to give it a try myself.

The new Macbook Pro’s at the time were released with a new keyboard, no ports, and they took away the function keys. This was enough of a change to make me look for another machine. A colleague of mine had been using a Dell XPS 9560 with much success so I also jumped on board.

These were the resources that I used to get up and running:

I remember feeling pretty great after starting the machine with the default config and seeing the default user login screen.

From there I was able to start adding packages to the system config, running nixos-rebuild switch and watch as it installed everything, ready to use.

Times that NixOS saved me

It’s interesting but I think these things below would have been avoidable using other operating systems. However, it was good to know that when things went wrong in the Linux world, I had an OS that let me experiment, knowing confidently that I just didn’t accidentally sink hours into something that would be destroyed with one wrong command.

NVIDIA drivers

I had some real trouble getting the NVIDIA drivers to play nice with my Dell XPS. When I got the configuration wrong, the machine would just flash some error (which I couldn’t see) and then reboot.

All I had to do was select my previous working NixOS generation at boot time, adjust the config and try again.

Windows updates

I had done something in my initial configuration where I had mounted a separate partition for my /home directory. And the way that I did that in my configuration was something like:

I was experimenting with C# and Visual Studio Code at the time so I did what I always did, which was to boot into Windows, do some work, Windows would apply software updates automatically and then I could just go back to NixOS.

There was one time (I think mid-2018) where this happened but after reboot, NixOS didn’t boot. In a desperate struggle to find out what was going on, I looked at the mount points and to my surprise, Windows had changed the ordering of the devices on my system - which means NixOS was no longer able to find my home partition.

Luckily, I had a recovery NixOS USB, which I booted from, mounted my home partition manually, made changes to the config to read the device by-partlabel instead, rebuild, reboot and everything was fine.

Kernel updates

There was a kernel update that broke my audio drivers. If I can find which one it was, I’ll post a link in an update. In any case, when I rebooted after the upgrade I lost audio in all of my applications.

Again, simply rolling back to the previous generation meant that I could continue with my day without getting blocked.

Linux on the desktop

Most of the issues that I had after making the switch, were with the current state of application quality on Linux. The applications that I had on OS X were excellent to use and they seamlessly blended with the OS features. This became less of an issue for me as I’m mostly doing software development these days.

However, I was pleasantly surprised to find mature software for things such as photo editing, vector graphics, animation and rendering, audio recording and editing. GIMP, Blender, Ardour - just to name a few.

A friend of mine wrote an excellent series on finding an alternative to OS X and this particular post has some great recommendations for software alternatives if you’re a software developer.

The Nix Package Manager

OK - a quick but related tangent. The basis of NixOS is the Nix package manager which comes with it’s own language in the form of Nix expressions. I’m sure that I’m not the first to say that it was completely unintuitive simply because my references for languages had been Java, Ruby, C, Javascript, etc - I had a really hard time doing anything.

When it came for me to configure my system with a different package version than the one in the Nixpkgs repo, I had no idea where to start. I had to look around and then saw that many folks just maintain a fork of the main repo and update packages as they need.

In fact this is what the NixOS guides recommend as the way to manage your own packages. Branching off one of the stable NixOS channels, make changes on a local branch and pull in upstream changes when you need an update from the community. This worked (and continues to work) really well.

As for writing my own Nix expressions, I had spent so much time trying to understand the syntax, language and core functions that I ended up putting it on the backburner indefinitely. I use the bare minimum of nix and nix-shell during my daily development, and it has been more than enough to keep me working efficiently. I’m yet to journey into using tools like bundix (for Ruby) and cabal2nix (for Haskell) but it is on my TODO list once the need to use them arises.

To be absolutely clear - I like what the Nix package manager and Nix expressions are reaching for. It is extremely powerful and I’m sure with some more reading and practice, I’d have no trouble being productive with it.

Closing thoughts

I won’t be switching back to OS X anytime soon.

Like most things, using NixOS (and Nix) has to align with your values as well as your current context and experience. At the time, I had troubles with upgrades and packages - I don’t have these issues anymore.

I was curious about Linux and wanted to learn more about the fundamentals of an operating system - not just the programming languages that I was using to build applications and services for end-users, but understand the infrastructure that I was deploying on daily.

I’ve learned many things by going on this journey. Things about operating systems, hardware, BIOS, boot sectors, partitioning, file system formats, kernels and much more. I always wanted to learn about these things, but never felt comfortable as a complete beginner to attempt working with them.

I was scared to try working with these things, simply out of the fear that I might have to sink hours and hours of time into resolving something that I accidentally broke - all because there wasn’t a fast and reliable rollback mechanism available to me.

NixOS enabled me to safely learn more about the software and tools that support my development environment - and for that I am very grateful.

Thanks for reading!