Skip to content

What is Nix and why it caught my attention

This is the first article in a series about my transition to NixOS. I'll tell you what pushed me to look for an alternative to traditional distros and why Nix caught my attention.

Problems with Ubuntu

I used Ubuntu for a long time and was generally happy with it, but over time the annoyances piled up:

  • Configuration scattered everywhere. System settings live in /etc, ~/.config, ~/.local, /var, in dconf, in snap packages, in Docker containers — there's no single source of truth. After a reinstall you have to remember what you configured and where.

  • Zero reproducibility. Installed a package six months ago, tweaked a config — and then you can't reproduce it on another machine. "Automation" scripts quickly become outdated and break.

  • Package conflicts. Different projects require different versions of the same libraries. PPA and snap partially solve the problem but add their own complexity.

  • Updates break the system. Upgrading from one LTS version to another is always a lottery. Something inevitably stops working and you spend time fixing things instead of working. My personal pain — the Wi-Fi driver 😅 Every time after an update I had to dig out a three-meter LAN cable, plug directly into the router, and figure out where to find and download the current one.

  • Fear of touching low-level stuff. I'm no Gentoo master — never built or patched kernels 😄 Editing kernel modules or GRUB configuration gave me cold sweats — one mistake and the system won't boot.

What is Nix

Nix is first and foremost a package manager with a fundamentally different approach.

  • Functional approach. Each package is a result of a pure function of its dependencies. No global state, no side effects during installation. Two packages with different versions of the same library coexist peacefully.

  • Declarativeness. Nix lets you describe environments declaratively — through configuration files instead of a sequence of commands. At the package manager level these are shell.nix, default.nix and flake.nix (formally experimental but de facto the standard in the community), while in NixOS this principle extends to the entire system.

  • Reproducibility. The same configuration yields the same result on any machine. You can store your config in git and roll back to any state — which is exactly what I do 😄

  • The Nix language. A custom functional language is used to describe packages and configuration. If you're familiar with FP it will seem simple — there aren't many constructs, but they're enough for flexible configuration of the entire system. I liked it so much that I wrote a library for building a Neovim bundle, where all configuration is assembled inside the package and doesn't depend on user settings — similar to the NixOS approach. I even made a separate nix2lua library for converting Nix to Lua 😊

First encounter

I learned about NixOS unexpectedly — as an active open source community member I started running into more and more people whose stuff didn't work specifically on NixOS 😄 I began looking into what this beast was, studying their configurations. Then flake.nix files started appearing in open-source projects and my curiosity got the best of me!

I didn't dare switch to NixOS right away — too radical. Instead I installed Nix as a package manager on top of Ubuntu.

The first thing I tried was nix-shell. The ability to enter a temporary environment with the packages you need without installing them system-wide — that's what I'd always been missing. Need nodejs, rust or ghc of a specific version for a project? One command — and you're in the environment, and after exiting the shell everything is clean. With Rust this is especially relevant — different projects support their own minimum version, and keeping them all on the system simultaneously was quite a headache.

nix-env for permanent package installation also worked, but the impressions were mixed — the imperative approach of nix-env doesn't reveal Nix's main advantages.

What truly hooked me was the feeling of control. The system stopped being a black box of accumulated changes. There was now a way to know exactly what's installed and why. And I wanted to go further.

What's next

In the next article I'll talk about home-manager — a tool that lets you declaratively manage your user environment configuration. That was my next step before fully switching to NixOS.