NixOS is a Linux distribution built on the Nix package manager and the Nixpkgs package collection. Instead of changing a running system piece by piece, the administrator describes the whole machine in configuration files. NixOS builds the system from that description. It runs on 64-bit Intel/AMD and ARM hardware, in virtual machines and on cloud servers. It suits desktops, servers and groups of machines alike. NixOS is free and open-source software; the Nixpkgs code is released under the MIT License, while the packages it builds keep their own licenses.
One file describes the whole system
The center of a NixOS installation is /etc/nixos/configuration.nix. This file states which kernel, boot loader, file systems, services, users and applications the machine should have. A line that enables the SSH server, for example, is enough for NixOS to install the daemon, generate its configuration file and start the service.
After editing the file, the administrator runs nixos-rebuild switch. NixOS downloads or compiles what is needed, builds the new system and activates it. The result depends only on the configuration, not on what was done to the machine before. Running the same file on another NixOS computer therefore reproduces the same kernel, software and services. Mutable data, such as files under /var, is not included.
Modules and options
The configuration is written in the Nix language and is organized as modules. Each module sets options with names such as networking.firewall.enable or environment.systemPackages, and an imports list can pull in other module files. NixOS merges all modules into one result. It combines lists set in several files. Conflicting single values stop the rebuild with an error unless one definition is explicitly given priority. The rebuild also catches undeclared option names and wrongly typed values. The project’s website provides a search for both packages and configuration options.
The Nix store and package isolation
NixOS does not use the usual /usr, /bin and /lib layout. Every package lives in its own directory in /nix/store. The directory name includes a cryptographic hash of everything used to build it. A change in any input produces a different path. Two versions or variants of the same library can therefore be installed side by side without conflict.
Generated configuration files are stored the same way. Most files in /etc are links to files in the store. User environments, called profiles, are sets of links pointing to the packages they include. Nix builds each package in isolation, where it can only see its declared dependencies. A package that builds on one machine therefore does not quietly depend on something else installed there.
Before building a package from source, Nix checks a binary cache for a ready-made copy with the same store path. If one exists, Nix downloads it. The project’s build servers fill the official cache as they test Nixpkgs and NixOS. Nixpkgs contains more than 140,000 packages.
Generations, rollbacks and safe testing
A rebuild never overwrites the previous system. Each successful nixos-rebuild switch creates a new generation, and older generations stay on disk. If an update causes problems, NixOS can switch back to the previous generation with a single command. Every generation also appears in the boot menu. A machine that no longer starts properly can therefore boot into an earlier working state.
Upgrades are atomic. If power fails in the middle of an update, the machine boots either the old or the new configuration, never a mixture of both.
NixOS offers several ways to try a change before relying on it:
- Test activation switches to the new configuration without making it the boot default, so a reboot returns to the known-good system.
- Boot-only changes make the new configuration the default for the next start without activating it immediately.
- Virtual machine builds create a QEMU virtual machine running the modified configuration. It shares no data with the host and needs no disk image, so it is a low-risk way to check a change.
Since old generations keep their packages in the store, disk usage grows over time. NixOS’s garbage collector removes store paths that no profile or running program uses. It can do this for all old generations or only for those older than a chosen age. The system configuration can schedule this cleanup automatically. Deleting old generations also removes the option of rolling back to them.
Installing software
NixOS has two ways of adding programs. The declarative way lists packages in environment.systemPackages; after a rebuild the system contains exactly that list. The imperative way uses the nix-env tool to install, upgrade or remove packages for one account. Ordinary users can install software this way without administrator rights, each in a separate profile. A package already built or downloaded for one user is reused for others. One user cannot alter a package another user depends on. User profiles have their own generations and rollbacks as well.
The same Nix tools can also define shareable development environments for projects in any programming language.
Release channels and updates
NixOS receives packages and system modules through channels, which are tested snapshots of Nixpkgs:
| Channel | What it provides |
|---|---|
| Stable | A release branch that receives conservative bug and security fixes |
| Small | A variant of the stable or unstable channel that updates faster but has fewer prebuilt binaries; suited to servers |
| Unstable | The main development branch, with newer software and more frequent changes |
An upgrade fetches the latest state of the chosen channel and rebuilds the system with it. This creates a new generation like any other change. NixOS can also upgrade itself on a schedule. When automatic reboots are allowed, it restarts only if the new generation changes the kernel, initial ramdisk or kernel modules.
Desktops, servers and containers
For desktop use, the graphical installer asks for language, time zone, keyboard layout, a user account and a desktop environment. GNOME and KDE Plasma are the main choices. A no-desktop option serves users who set up their own window manager. Configuration options switch on display managers, desktop environments, networking through NetworkManager and the firewall. A minimal installation image without a graphical interface is available for servers and manual setups. The project publishes images for Amazon Web Services.
NixOS can also run lightweight containers, each one a separate NixOS system based on systemd-nspawn. The host’s configuration defines a container with its own NixOS settings. The container can start automatically with the host. It can receive a private network interface with its own address or share the host’s network.




