NixOS Series #1: Why Should You Consider Using NixOS?

NixOS… Yet another distro that uses a different package manager? ๐Ÿคฏ

Well, NixOS is one of the advanced Linux distros.

So if I’m writing this, I must have a rock-solid reason, right? Well, there are plenty!

I’ve been using it for 3 months, and it is so good that I’m considering switching from my all-time favorite Pop!_OS to NixOS.

And in this guide, I will share the key features of NixOS, making it stand out from the stack of Linux distros.

Fret not; before we move on, let me tell you what NixOS is:

It is a Linux distribution that uses the Nix package manager at its core to save you the trouble from setting it up on a different Linux distribution and letting you make the most out of Nix. Built by the same team that developed Nix.

6 Reasons to Use NixOS

NixOS is an interesting independent Linux distro built from scratch.

Everyone can learn a lot by using NixOS, but in my opinion, if you are a developer or a computer science student, NixOS should fit perfectly.

NixOS Series #1: Why Should You Consider Using NixOS?

Let me tell you why.

1. Does Not Break Easily / Easy to Recover

By its core, NixOS is built to last long.

This does not mean that it ships with years-old packages like Debian does for stability but it follows a different approach.

To understand how NixOS is so stable, let’s talk about how users generally break their system, i.e, “dependency issues or package conflicts

You will generally face a significant system crash when updating your system or installing a new package. Mainly because your package manager could not satisfy the dependency or the installed package conflicts with the existing system.

And NixOS has a very smart way of handling this issue.

See, whenever you upgrade your system or install a package, the system state is rebuilt, termed as a “new generation” over the current.

NixOS Series #1: Why Should You Consider Using NixOS?

So if you face any trouble using the new package or update, you can always roll back to the old generation, where you will find the previous state of the system.

Even if the system is inaccessible, you will find the previous generations available at boot time.

2. Reproducibility

With one config file, you can create a replica of your current environment for other physical systems.

To benefit from this feature, you can use the Nix config file for installation and configuration purposes.

Once you have the config file that fits your purpose, send that file to the fresh install and replace the default config file with yours. It is that easy!

Rebuild the config, upgrade the system, and make a switch by the given command:

sudo nixos-rebuild switch --upgrade

And you will have the exact development environment that you had on your main machine replicated in a few minutes.

3. ย Easy Rollbacks

While you already may have got the idea from NixOS’s feature of “Generations“.

There’s more to it. ๐Ÿ•ต๏ธ

NixOS heavily relies on symlinks (for good). If it is a new concept to you, refer to the guide below:

How to Create Symbolic Links in Linux [Complete Guide]
This detailed tutorial tells you what are symbolic links, how to create a symbolic links and other important things associated with symlinks.
NixOS Series #1: Why Should You Consider Using NixOS?

Typically, with other Linux distros, when you upgrade a package, the new package replaces the old one.

But that’s not the case with NixOS.

In NixOS, packages are isolated and stored inside a unique directory, and that is where the use of symbolic links comes in.

Whenever you upgrade a package, the NixOS will tune the symbolic link to locate the new package but won’t remove the old one.

So if you face conflicts with the new package, just switch to the old generations, and symbolic links help locate the old version of a package. ๐Ÿ˜Œ

4. Nix package manager

The Nix package manager allows you to access more than 80,000 packages! Not just limited to Linux; it also works on macOS, WSL2, Docker, and more platforms.

And the availability of packages is similar to or even better than AUR as you should find almost everything (I mean it) on the Nix package manager.

For instance, I wanted to install the Librewolf browser, which is not available in the default repository of most Linux distros.

But Nix had it! This means you can rely on the Nix package manager for almost every package.

It is also relatively easy to understand if you have prior Linux experience. In a nutshell, the Nix package manager is impressive!

5. Use multiple versions of the same package

This can be crucial for developers, where some applications demand the old version of a specific dependency, whereas some require the latest one.

And as I mentioned earlier, nix installs packages to a specific sub-directory, and every package is isolated so one won’t interfere with another!

Before using Nix, I used VMs and containers to meet different dependencies for the same package, especially with PHP, but NixOS did wonders for my workflow.

Suggested Read ๐Ÿ“–

Downgrading a Package via apt-get in Ubuntu and Debian
Yes! Thatโ€™s totally possible. You can downgrade a recently updated package using the apt command in Ubuntu and Debian based distros. Hereโ€™s how to do that.
NixOS Series #1: Why Should You Consider Using NixOS?

6. Ability to test packages without installation

You can use the nix-shell, which will temporarily modify the $PATH environment variable and be used to test a package temporarily.

And there is no limitation. You are allowed to test every package that is available for installation!

NixOS Series: Let’s Explore More!

This was the first part of our Nix series, where I covered the reasons to use NixOS. I believe more Linux users should get to learn about it if they do not already.

In the next part, I will explain how to install NixOS in your VM. Stay tuned to our social media or RSS feed to read when we publish that.

๐Ÿ’ฌ Feel free to share suggestions on what else we should cover about NixOS in the comments below.

Leave a Comment