NixOS is a Linux distribution built on the Nix package manager in which the entire operating system, including packages, services, users and kernel settings, is described in declarative configuration files and built from them. Among Linux distributions it stands apart because it treats the system as a reproducible build artifact rather than a machine modified step by step.
This design gives NixOS atomic upgrades, instant rollbacks and the ability to recreate an identical system on another machine from the same configuration. The price is a steeper learning curve and a filesystem layout that differs sharply from the conventions shared by Debian, Fedora and Arch Linux.
How NixOS builds the operating system
NixOS rests on the purely functional package model of Nix. Each package is built by a derivation, a precise description of its sources, dependencies and build steps, and the result is stored in the Nix store under a path containing a cryptographic hash of all those inputs, such as /nix/store/abc123-openssl-3.0.13.
Because the hash changes whenever any input changes, multiple versions of the same library coexist without conflict. Programs reference exact store paths for their dependencies, which removes the classic dependency hell caused by a single shared /usr/lib directory.
The system itself is produced the same way. The command nixos-rebuild switch evaluates the configuration, builds a new system generation in the store, updates the boot menu and activates the result. Older generations remain intact, so the previous system is one reboot or one command away.
| Component | Role | Practical effect |
|---|---|---|
| Nix language | Lazy, functional configuration language | Systems expressed as code |
| Nix store | Immutable, hash-addressed package storage | Versions never overwrite each other |
| Nixpkgs | Central collection of package definitions | Over 100,000 packages available |
| NixOS modules | Typed options for services and settings | Services enabled with one option |
| System generations | Complete, bootable system snapshots | Instant rollback after bad changes |
Declarative configuration and flakes
In NixOS, administrators describe the desired state instead of running installation commands. A file such as /etc/nixos/configuration.nix states that SSH is enabled, which users exist and which packages are installed, and the module system translates those options into configuration files and systemd units.
Flakes add a standardized project structure with a lock file that pins every input, including the exact Nixpkgs revision. With flakes, a configuration produces the same system on any machine and at any time, which matters for fleets, continuous integration and disaster recovery. Flakes are widely used, although they are still formally marked as experimental in Nix.
The declarative model also changes how drift is handled. Manual edits under /etc are generally overwritten or impossible, because most of those files are links into the read-only store. Any lasting change must go through the configuration, which keeps the system documented by construction.
NixOS compared with other Linux distributions
NixOS differs from mainstream distributions mostly in how state and change are managed, not in the kernel or desktop software it ships. The table below contrasts it with three common reference points in the Linux fundamentals landscape.
| Distribution | Package model | System changes | Rollback |
|---|---|---|---|
| NixOS | Hash-addressed store, many versions | Declarative rebuild | Built in, per generation |
| Debian | Shared filesystem, one version | Imperative package commands | Manual or snapshot-based |
| Fedora Silverblue | Image-based base with containers | Atomic image updates | Previous image retained |
| Arch Linux | Rolling binary packages | Imperative, user-maintained | Manual or snapshot-based |
NixOS is not the only atomic distribution, but it is unusual in being declarative and reproducible at the same time. Image-based systems guarantee a consistent base, whereas NixOS describes every service and setting in one configuration that can be reviewed in version control.
When NixOS is a good choice
NixOS fits best where reproducibility and controlled change matter more than familiarity. The following decision table summarizes typical situations and whether its model pays off.
| Situation | Recommendation | Reason |
|---|---|---|
| Server fleet managed as code | Strong fit | Identical, auditable machines |
| Developer workstations | Good fit | Per-project environments without conflicts |
| Homelab experimentation | Good fit | Safe rollback after failed changes |
| Proprietary vendor software | Weak fit | Installers expect standard paths |
| Team without Nix experience | Caution | Learning curve slows early delivery |
Developers often adopt Nix before NixOS. The command nix develop or a shell.nix file provides isolated per-project toolchains on any Linux distribution or macOS, and teams that like that workflow later extend it to the whole operating system.
Limitations and common pitfalls
The main obstacle is the Nix language and its error messages, which can be cryptic, especially in lazily evaluated code. Documentation has improved but remains uneven, and many solutions exist only in community discussions or in the Nixpkgs source itself.
- Precompiled binaries often fail because they expect a dynamic loader at standard paths; tools such as
nix-ldor patching withpatchelfare required. - Disk usage grows as generations accumulate; garbage collection with
nix-collect-garbagemust be scheduled. - Imperative habits break, since editing files under
/etcor installing with ad hoc commands bypasses the configuration. - Secrets need special handling, because everything in the store is world-readable; dedicated tools such as sops-nix or agenix are used.
None of these issues is fatal, but together they mean that NixOS rewards deliberate investment. Teams that treat it like a conventional distribution usually struggle, while teams that embrace configuration as the single source of truth gain its full benefits.
Explained without jargon
Most computers are set up by changing things one at a time. After a few years, nobody remembers how the machine got its current shape. NixOS works differently. The whole computer is described in a written plan, and the system is built from that plan.
If an update breaks something, the previous version is still stored. It can be picked at startup, much like undoing a change in a document. The same plan also produces an identical computer elsewhere, which saves hours when replacing or adding machines.
A typical use case
A small infrastructure team runs 25 Linux servers for web applications, databases and monitoring. Before switching, each server had been configured by hand over several years, and two supposedly identical web servers behaved differently because of forgotten manual changes.
The team moved the servers to NixOS and stored a single flake in a Git repository, with shared modules for hardening, logging and monitoring and small per-host files for roles. Every change goes through a code review and is deployed with nixos-rebuild to a staging host first. When a kernel update caused a network driver problem on two machines, the team rolled back to the previous generation in under five minutes.
After a year, rebuilding a failed server dropped from about a day to under an hour, and an external security audit used the repository itself as the authoritative description of every machine.