Why even bother with NixOS?

08 apr, 2024 10 Min. read

For years, I was a loyal Arch Linux user. It provided a solid foundation, but eventually I craved a new challenge. While I appreciate Arch’s DIY approach, I started to find the initial setup process tedious, especially for repeat installations.

One day, while browsing YouTube, I stumbled upon a Chris Titus Tech video about NixOS. Initially the concept went over my head, and I didn’t consider trying it at the time. However, the idea of NixOS lingered in the back of my mind. Eventually curiosity prevailed, and I decided to give it a shot. (Let’s just say my first two attempts involved some user error!)

A Comedy of Errors

My first attempt at NixOS was a masterpiece of user incompetence. I skimmed the wiki like a squirrel crossing a highway, ending up with an unstable Nvidia driver that made my desktop look like a Dali painting. Needless to say, I retreated back to the familiar arms of Arch Linux.

The second time around, I was all set to conquer NixOS. Except, the downloads were slower than watching paint dry on a sloth’s back. Back then, I was rocking a mobile data connection with an “unlimited” plan that only applied between the witching hour and sunrise (12 - 6). Great for vampires, terrible for Linux updates. Since compiling packages in NixOS takes longer than a nap, waiting until after midnight to download became a real drag, especially when that itch to play games hit. So, back to Arch I went.

Fast forward to the present day, with a blazing-fast broadband connection at my disposal. NixOS, round three! This time, with actual knowledge and a decent internet connection, I finally managed to tame the beast. Now, I’m a happy NixOS daily driver, proving that even with some hilarious missteps, the journey can be worth it.

Why I found NixOS Fascinating

Declarative Configuration

NixOS shines with its declarative configuration, you define your entire system in a single configuration file. Imagine a blueprint – everything from packages to services is declared in code, making it easy to understand, manage, and keep track of changes with version control.

Vast Package Repository

image

The Nix package repository is a behemoth, even larger than the famous AUR (Arch User Repository). It offers a plethora of software, including Node.js packages, GNOME extensions, and even browser extensions. Still can’t find what you need? NUR (Nix User Repository) might have it. As a last resort, you can package it yourself, but beware - the Nix documentation can be a bit rough around the edges.

More to Explore

NixOS boasts a wealth of features beyond my current needs – declarative development environments, cloud images, and minimal Docker containers, to name a few. I’m sure they’ll come in handy in the future

The Cool Factor

Let’s be honest, NixOS has a cool name and logo. Who wouldn’t want to be part of the Chad club of Linux users? (Okay, maybe that’s a bit tongue-in-cheek, but it does look pretty slick!)

Modular Configuration

As a developer, I value clean, modular structures. NixOS takes this concept, allowing you to build your entire system configuration with a clear and maintainable file structure. It’s like writing elegant code for your system – a practice many would consider an art form.

If you’ve explored NixOS, you’ve likely encountered terms like “home-manager” and “flakes.” These tools empower you to truly master your system. Let’s delve into how they work:

Home Manager

True to its name, home-manager focuses on configuring your home directory. This allows for diverse user setups, with each user having a unique configuration. Think of it as managing your ~/.dotfiles on steroids. You can install software specific to your preferences, ensuring that your environment perfectly matches your workflow.

There are two installation methods: standalone and as a NixOS module. Here’s why I prefer the standalone approach:

Rootless Rebuilds: No need for sudo when rebuilding your configuration. Independent Execution: Runs independently of system rebuilds, saving you time.

Home-manager generations can pile up faster than leaves in autumn. I wrote a script to bulk clean those pesky home-manager generations! You’re welcome (and your sanity will thank you later).

Flakes

Flakes are another layer of abstraction, offering exciting possibilities for managing your NixOS experience. They introduce a powerful concept: reproducible and composable package management. Flakes utilize a file called flake.lock to track every package and its specific version. This meticulous version control ensures a consistent system experience across environments.

Centralized Configuration, Elegance and Efficiency: Beyond individual tools, both home-manager and system configurations can be defined within a single flake.nix file. This streamlines the process – you can create a global configuration files like global-config.nix and easily integrate them with your system and home-manager setups, so when you want quick edit something for example fonts you don’t have to go through each and every file for example your terminal, vscode, browser, and any other apps you use.

A Configurable Chameleon: Flakes are also instrumental in managing configurations for multiple devices. Whether you have a desktop and a laptop, flakes empower you to maintain distinct, optimized configurations for each machine.

In essence, NixOS offers a unique approach to system configuration. With its modular tools and emphasis on clean file structure, it empowers you to build a system that not only functions flawlessly but also reflects your own personal style.

What I don’t like about NixOS?

NixOS is undeniably impressive, but like anything, it’s not flawless. Transitioning from other distributions may require adjustments in a few areas:

Longer Download/Build Times

NixOS excels in package management, but initial installations or updates involving missing packages can be slower, not exactly ideal if you’re impatient. This is because NixOS prioritizes building from source code whenever possible, ensuring a highly customized and reproducible system. While pre-build binaries are available in the cache cache.nixos.org, missing packages will require downloading and building the source code. If you have slow internet connection or limited time, the initial setup might take longer. The good news is that subsequent rebuilds, once the packages are cached, are significantly faster.

Non-Standard Directory Structure

NixOS has its own way of organizing things which can differ from the Filesystem Hierarchy Standard (FHS) used by most other Linux distributions, it’s like finding your socks in a different drawer after moving. This means some locations such as /bin where Linux stores all binary packages for example ls, cd, unzip,neofetch etc. Or maybe /usr/share/applications where you usually find .desktop entries, or /usr/share/themes etc. Also you might need to adjust shell scripts to use #!/usr/bin/env bash which are already using good ol’ #!/bin/bash, while this can be a minor inconvenience for experienced users, it’s an important consideration for those transitioning from other distros.

Occasional Limitations in Package Availability

The Nix package repository is a treasure trove, but there’s always a chance you might strike out on a specific program. Remember that audio sharing tool you wanted? (for me it’s AudioRelay) NixOS might not have it readily available. Don’t worry, you can package it yourself, but that process can feel like navigating a maze blindfolded! Thanks to Nix docs. Just a heads-up to check the Nix package repo before switching over and make sure your must-have software is there.

Additionally, there’s the NUR(Nix User Repository) similar to AUR, which you might find worth exploring. If you’re lucky, the missing packages you seek could be listed there.

Also quick FYI: running AppImages in NixOS requires a little extra step. Unlike most distros, simply making an AppImage executable won’t work. You’ll need to install a package called appimage-run. Then, you launch the AppImage with appimage-run whatever.appimage or just register appimage files as a binary type mentioned in NixOS wiki. Even with appimage-run, not all AppImages are guaranteed to work. For example, I tried running Rustdesk with appimage-run but encountered an Exec format error.

Furthermore, encountering errors when trying to run binaries from random git repositories is common:

NixOS cannot run dynamically linked executables intended for generic

Thankfully, solutions exist, The easy way is flatpak, while the more challenging route involves a package called nix-ld. It’s worth exploring both options to find the best fit for your needs.

Even though the documentation may not be the most well-written, if you’re just starting out and focusing on basic configurations, you should be fine. However, it becomes more challenging when you dive into more complex tasks like running containers or packaging software.

Target Audience

Many of us who are new to NixOS, myself included, used to be avid users of Arch Linux. Why the change? Well, according to some, it’s because Arch isn’t isn’t cool anymore. While that’s true to an extent, the real reason is that people like us thrive on exploring new technologies and embracing challenges, even when they’re tough. It’s like a nerdy adventure that gives us a sense of accomplishment. As for impressing the ladies with our Linux skills, let’s just say the reality check hits harder than a failed system update. Anyway, let’s get back to why NixOS is a big deal now.

While some critics argue that NixOS isn’t a Linux distribution at all, let’s just say they have a different dictionary edition. It’s like debating whether pineapple belongs on pizza, ultimately, it’s just a part of what makes pizza either good or bad—it’s all about perspective. NixOS is like a specialized tool for software developers and businesses, not ment your everyday operating system.

So, if you’re up for a challenge, enjoy learning new things, or just want a stable system that doesn’t budge, NixOS might just be your cup of tea or coffee if you prefer. Just remember to embrace both the perks and quirks along the way and not to install it on you grandma’s PC.

Few Useful Stuff worth knowing

There is Nix Software Center, a graphical app store for Nix.

nix software center

Also NixOS Configuration Editor from same developer

NixOs Config Editor

So, there’s a possibility that it could evolve into a cutting-edge, rock solid, user-friendly system in the future.

If you’re a beginner who’s just starting out or planning to switch to NixOS, I highly recommend grasping its fundamentals first. YouTube videos can be incredibly helpful for this—I particularly recommend the Vimjoyer’s. Additionally, there are some websites you can benefit from, such as the NixOS & Flakes Book and Zero to Nix. Be sure to check out Awesome Nix as well—it’s a fantastic resource for discovering a wealth of information about Nix.

Conclusion

Nix is unique, I personally didn’t find Nix itself that tough. It was kind of like a fun puzzle from start to finish, let’s be honest, having programming knowledge helped a lot, because you know how to properly find something on the internet. One thing that I, and a lot of Nix users, still find hard is error logs, pure gibberish from another dimension. Debugging can feel like you need a decoder ring and a Ph.D. in alien languages. But despite its tradeoffs, the benefits it provides currently outweigh the disadvantages.

Now, I agree with others that NixOS can be a beast if you’re new to coding. It kind of shoves you into learning this Nix language, which isn’t exactly a walk in the park (even for programmers). But hey, everything has its pros and cons, right? You gotta weigh them, decide if you can deal, and move on. That’s what I did. NixOS is pretty awesome, but I learned to accept its flaws and just roll with them.