Written in | Nix expression language |
---|---|
OS family | Unix-like |
Working state | In development |
Source model | Open source |
Initial release | 2003 |
Latest release | 16.09 / October 3, 2016 |
Marketing target | General purpose |
Package manager | Nix |
Platforms | x86-64 |
Kernel type | Monolithic (Linux kernel) |
License | MIT |
Official website | nixos |
NixOS is a Linux distribution built on top of the Nix package manager. It uses declarative configuration and allows reliable system upgrades. Two main branches are offered: current Stable release and Unstable following latest development.
Although NixOS started as a research project, it is a fully functional and usable operating system.
NixOS is DevOps friendly and has tools dedicated to deployment tasks.
NixOS started as a research project by Eelco Dolstra in 2003.
In 2015 the NixOS foundation was started to help projects supporting the purely functional deployment model like NixOS.
In NixOS, the entire operating system — the kernel, applications, system packages, configuration files, and so on — is built by the Nix package manager from a description in a functional build language. It means that building a new configuration cannot overwrite previous configurations.
A NixOS system is configured by writing a specification of the functionality that the user wants on their machine in a global configuration file. For instance, here is a minimal configuration of a machine running an SSH daemon:
After changing the configuration file, the system can be updated using the nixos-rebuild switch
command.
This command does everything necessary to apply the new configuration, including downloading and compiling packages and generating configuration files.
Since Nix files are pure and declarative, evaluating them will always produce the same result, regardless of what packages or configuration files are on the system. Thus, upgrading a system is as reliable as reinstalling from scratch.
NixOS has a transactional approach to configuration management making configuration changes such as upgrades atomic. This means that if the upgrade to a new configuration is interrupted — say, the power fails half-way through — the system will still be in a consistent state: it will either boot in the old or the new configuration. In other systems, a machine might end up in an inconsistent state, and may not even boot anymore.
If after a system update the new configuration is undesirable, it can be rolled back using a special command (nixos-rebuild switch --rollback
).
In fact, every system configuration versions automatically show up at the system boot menu. If the new configuration crashes or doesn’t boot properly, an older version can be selected. Also, rollbacks are a lightweight operation that do not involve files to be restored from copies.