HOME

TheInfoList



OR:

NixOS is a
Linux distribution A Linux distribution (often abbreviated as distro) is an operating system made from a software collection that includes the Linux kernel and, often, a package management system. Linux users usually obtain their operating system by downloading one ...
built on top of the
Nix package manager Nix is a cross-platform package manager that utilizes a purely functional deployment model where software is installed into unique directories generated through cryptographic hashes. It is also the name of the tool's programming language. A pa ...
. It uses declarative configuration and allows reliable system upgrades. Several official package "channels" are offered, including the current Stable release and the Unstable release which follows the latest development. NixOS has tools dedicated to
DevOps DevOps is a set of practices that combines software development (''Dev'') and IT operations (''Ops''). It aims to shorten the systems development life cycle and provide continuous delivery with high software quality. DevOps is complementary to ...
and deployment tasks.


History

In 2003, Eelco Dolstra started NixOS as a research project. In 2015, the
Stichting A ''stichting'' () is a Dutch legal entity with limited liability, but no members or share capital, that exists for a specific purpose. This form of entity makes it possible to separate functions of ownership and control. Its use has been pioneered ...
NixOS was founded aiming to support projects like NixOS that implement the purely functional deployment model.


Versions

NixOS publishes releases on a twice a year schedule. This used to happen around March and September but, starting with 21.05, NixOS targets May and November instead. Each version number has the format "YY.MM", for instance "20.03" was the version released in March 2020. Each version of NixOS has a name, such as "Markhor" for the release 20.03.


Features


Declarative configuration model

In NixOS, the entire operating system – the
kernel Kernel may refer to: Computing * Kernel (operating system), the central component of most operating systems * Kernel (image processing), a matrix used for image convolution * Compute kernel, in GPGPU programming * Kernel method, in machine learn ...
, applications, system packages,
configuration files In computing, configuration files (commonly known simply as config files) are files used to configure the parameters and initial settings for some computer programs. They are used for user applications, server processes and operating syste ...
, and so on – is built by the Nix package manager from a description in a functional build language. This 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.


Reliable upgrades

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.


Atomic upgrades

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.


Rollbacks

If after a system update the new configuration is undesirable, it can be rolled back using a special command (nixos-rebuild switch --rollback). Every system configuration version automatically shows up at the system boot menu. If the new configuration crashes or does not boot properly, an older version can be selected. Rollbacks are lightweight operations that do not involve files being restored from copies.


Reproducible system configurations

NixOS's declarative configuration model makes it easy to reproduce a system configuration on another machine. Copying the configuration file to the target machine and running the system update command generates the same system configuration (kernel, applications, system services, and so on) except for parts of the system not managed by the package manager such as user data.


Source-based model with binary cache

The Nix build language used by NixOS specifies how to build packages from source. This makes it easy to adapt the system to user needs. However, building from source being a slow process, the package manager automatically downloads pre-built binaries from a cache server when they are available. This gives the flexibility of a source-based package management model with the efficiency of a binary model.


Consistency

The Nix package manager ensures that the running system is consistent with the logical specification of the system, meaning that it will rebuild all packages that need to be rebuilt. For instance, if the kernel is changed then the package manager will ensure that external kernel modules will be rebuilt. Similarly, when a library is updated it ensures that all the system packages use the new version, even packages statically linked to it.


Multi-user package management

There is no need for special privileges to install software in NixOS. In addition to the system-wide profile, every user has a dedicated profile in which they can install packages. Nix also allows multiple versions of a package to coexist, so different users can have different versions of the same package installed in their respective profiles. If two users install the same version of a package, only one copy will be built or downloaded. Nix's security model ensures that this is secure because only the users explicitly trusted by the system configuration are allowed to use build parameters that would allow them to control the content of a derivation's output (such as adding impurities to the sandbox or using an untrusted substituter ). Without those parameters, paths can only be substituted from a substituter trusted by the system or a local sandboxed build which is implicitly trusted.


Implementation

NixOS is based on the Nix package manager that stores all packages in isolation from each other in the package store. Installed packages are identified by a cryptographic hash of all input used for their build. Changing the build instructions of a package modifies its hash and that will result in a different package installed in the package store. This system is also used to manage configuration files ensuring that newer configurations are not overwriting older ones. An implication of this is that NixOS doesn't follow the
Filesystem Hierarchy Standard The Filesystem Hierarchy Standard (FHS) is a reference describing the conventions used for the layout of a UNIX system. It has been made popular by its use in Linux distributions, but it is used by other UNIX variants as well. It is maintained b ...
. The only exceptions are a symlink /bin/sh to the version of
bash Bash or BASH may refer to: Arts and entertainment * ''Bash!'' (Rockapella album), 1992 * ''Bash!'' (Dave Bailey album), 1961 * '' Bash: Latter-Day Plays'', a dramatic triptych * ''BASH!'' (role-playing game), a 2005 superhero game * "Bash" ('' ...
in the Nix store (like this: /nix/store/s/5rnfzla9kcx4mj5zdc7nlnv8na1najvg-bash-4.3.43/); and while NixOS does have an /etc directory to keep system-wide configuration files, most files in that directory are symlinks to generated files in /nix/store such as /nix/store/s2sjbl85xnrc18rl4fhn56irkxqxyk4p-sshd_config. Not using global directories such as /bin is part of what allows multiple versions of a package to coexist.


Reception

Jesse Smith, reviewing NixOS 15.09 for DistroWatch Weekly wrote: DistroWatch Weekly also has a review of NixOS 17.03, written by Ivan Sanders. A 2022 review of NixOS 21.11 "Porcupine" in
Full Circle magazine ''Full Circle'' is a free distribution Portable Document Format magazine that was founded by Ronnie Tucker in April 2007. It is released on the last Friday of every month in PDF, EPUB ebook format and also on the Issuu electronic publishing platfo ...
concluded:


See also

*
Nix package manager Nix is a cross-platform package manager that utilizes a purely functional deployment model where software is installed into unique directories generated through cryptographic hashes. It is also the name of the tool's programming language. A pa ...
– The package manager upon which NixOS is based *
GNU Guix System GNU Guix System or Guix System (previously ''GuixSD'') is a rolling release, free and open source Linux distribution built around the GNU Guix package manager. It enables a declarative operating system configuration and allows reliable system ...
– An operating system built on
GNU Guix GNU Guix () is a functional cross-platform package manager and a tool to instantiate and manage Unix-like operating systems, based on the Nix package manager. Configuration and package recipes are written in Guile Scheme. GNU Guix is the defaul ...
that is inspired by Nix


References


External links

* *
Nix packages repository

Unofficial NixOS Wiki
{{Linux Independent Linux distributions Linux distributions Operating system security Source-based Linux distributions X86-64 Linux distributions