Why I prefer NixOS

NixOS, along with its Nix package manager, introduces some very unique concepts that set it apart from traditional Linux distributions. Here’s a detailed breakdown of its advantages:


1. Declarative System Configuration

  • What it is: In NixOS, your entire system configuration—including installed packages, services, system settings, and user environments—is described in a single configuration file (/etc/nixos/configuration.nix).
  • Advantages:
    • Reproducibility: You can reproduce the same system on another machine by copying the configuration file.
    • Rollback: If a change breaks your system, you can revert to a previous configuration with a single command (nixos-rebuild switch --rollback).
    • Version Control Friendly: Your entire system setup can be tracked in Git, making system changes auditable and shareable.

2. Atomic Upgrades and Rollbacks

  • What it is: Nix builds packages in isolation and stores them in unique paths in /nix/store. This allows multiple versions of the same package to coexist.
  • Advantages:
    • Safe upgrades: Installing or upgrading software never overwrites other versions, so updates can’t break existing programs.
    • Instant rollback: You can revert system updates or package upgrades without affecting other parts of the system.
    • No “dependency hell”: Multiple versions of libraries can coexist without conflicts.

3. Purely Functional Package Management

  • What it is: Nix treats packages like pure functions: the output depends solely on the input (dependencies, build instructions).
  • Advantages:
    • No hidden dependencies: Builds are reproducible because all dependencies are explicitly defined.
    • Predictable builds: Your packages work the same way on any NixOS system, and even on other Linux distros with Nix installed.
    • Isolated environments: Using nix-shell, you can create per-project development environments without polluting the global system.

4. Multi-Version and Multi-User Support

  • What it is: Because Nix stores packages with unique hashes, multiple users can safely install different versions of the same package without interfering with each other.
  • Advantages:
    • No sudo for installs: Users can install software in their own environments.
    • Consistency across environments: Each user can have exactly what they need without risking system stability.

5. Reproducible and Portable Development Environments

  • What it is: Nix allows creating isolated development environments via nix-shell or direnv + nix.
  • Advantages:
    • Cross-machine consistency: Developers can guarantee that their environment is identical to production or other developers’ setups.
    • No global pollution: Dependencies are local to the environment, avoiding conflicts with other projects.

6. Rollback-Safe Configuration Changes

  • What it is: Because NixOS manages the system declaratively and stores previous generations, you can test risky changes safely.
  • Advantages:
    • Easy experimentation: You can try new versions of software or change system settings without fear of breaking your system.
    • Instant recovery: If a new kernel or package update fails, you can boot into the previous generation.

7. Clean Package Management

  • What it is: Nix keeps every package in /nix/store with unique names based on dependencies.
  • Advantages:
    • No leftover cruft: Uninstalling a package removes all associated files.
    • No conflicts: Installing one version of a library never overwrites another version used by a different program.
    • Garbage collection: Unused packages can be safely removed without affecting anything else (nix-collect-garbage).

8. Cross-Distribution Portability

  • What it is: Nix can be installed on other Linux distros or macOS.
  • Advantages:
    • Use Nix features everywhere: Even if you don’t switch fully to NixOS, you can use reproducible builds and isolated environments on your existing system.
    • Standardized workflows: Developers can maintain the same development workflows across multiple OSes.

9. Large, Up-to-Date Package Repository

  • What it is: Nixpkgs, the Nix package collection, contains thousands of packages and is constantly updated.
  • Advantages:
    • Modern software versions: You often get newer versions than distributions like Debian stable.
    • Automated builds: Packages are built reproducibly from source or binaries.

10. Security Advantages

  • Isolation: Packages are isolated in /nix/store, reducing the risk that a compromised package can interfere with others.
  • Immutable builds: Because builds are purely functional, a compromised dependency cannot silently alter other packages.

NixOS vs Traditional Linux: Quick Cheat Sheet

FeatureNixOSTraditional Linux (Ubuntu/Debian/Fedora)
System ConfigurationDeclarative via /etc/nixos/configuration.nixAd hoc config files scattered across /etc
Package ManagementNix: purely functional, isolated, multiple versions coexistStandard package managers (apt, dnf, pacman) with single-version installations
Upgrades & RollbacksAtomic upgrades, full rollback to previous system stateUpgrades can break system; rollbacks usually complex
ReproducibilityGuaranteed across machinesHarder to replicate exactly due to system drift
Development EnvironmentsIsolated per-project via nix-shellTypically global, may need Docker or virtual environments
Disk UsageHigher; multiple versions stored in /nix/storeLower; usually only one version of each package
Learning CurveSteep; requires learning Nix expressionsGentle; well-known commands and workflows
GUI / Desktop ToolsLimited; mainly CLIRich GUI tools and apps
Community & DocumentationSmaller, niche-focusedLarge, extensive, widely supported
Hardware SupportGood, but some drivers need manual configurationExcellent, widely tested on mainstream hardware
Best ForDevelopers, sysadmins, reproducible servers, multi-version projectsCasual desktop use, gaming, office work, beginners

Summary

In short, NixOS and the Nix package manager prioritize reproducibility, safety, and flexibility over the traditional Linux approach. Compared to mainstream distros:

FeatureNixOSTypical Linux (Debian/Ubuntu/Fedora)
System configurationDeclarative, version-controlledAd hoc, scattered config files
UpgradesAtomic, rollback-safeRisk of breaking system
Package versionsMultiple versions coexistUsually only one version
ReproducibilityGuaranteedOften hard to replicate exactly
IsolationStrong (purely functional)Weak (global file paths, shared libs)
Development environmentsLocal, reproducible (nix-shell)Often requires Docker or manual setup

Leave a Comment

Licensed under CC BY-NC 4.0

DevOps viewpoints are those of its owner. You may share and adapt this article for non-commercial purposes, provided proper attribution is given. Attribution should include:

Title: Why I prefer NixOS
Author: peter arthur martin
Original URL: https://www.woodcentral.com/-/peter/why-i-prefer-nixos/
License: CC BY-NC 4.0

Site Index

👍 This page answered my questions

Your vote helps other woodworkers quickly find the answers and techniques that actually work in the shop.