NixOS: Difference between revisions
imported>HLandau |
imported>Ixxie Restructured `Comparison with tradition Linux distributions` and removed stub header. |
||
| Line 1: | Line 1: | ||
[https://nixos.org/ NixOS] is a Linux distribution based on the [[Nix Package Manager]]. It supports reproducible and declarative system-wide configuration management as well as atomic upgrades and rollbacks, although it can additionally support imperative package and user management. In NixOS, all components of the distribution — including the kernel, installed packages and system configuration files — are built by [[Nix Package Manager|Nix]] from purely functional (that is, [[Wikipedia:Pure function|side-effect free]]) [[Nix Expression Language|Nix expressions]]. | [https://nixos.org/ NixOS] is a Linux distribution based on the [[Nix Package Manager]]. It supports reproducible and declarative system-wide configuration management as well as atomic upgrades and rollbacks, although it can additionally support imperative package and user management. In NixOS, all components of the distribution — including the kernel, installed packages and system configuration files — are built by [[Nix Package Manager|Nix]] from purely functional (that is, [[Wikipedia:Pure function|side-effect free]]) [[Nix Expression Language|Nix expressions]]. | ||
| Line 160: | Line 158: | ||
== Internals == | == Internals == | ||
=== | === Comparison with traditional Linux Distributions === | ||
''Main Article: [[Nix vs. Linux Standard Base]]'' | |||
<code>/bin</code> and <code>/ | The main difference between NixOS and other Linux distributions is that NixOS does not follow the [https://en.wikipedia.org/wiki/Linux_Standard_Base Linux Standard Base] file system structure. On LSB-compliant systems software is stored under <code>/{,usr}/{bin,lib,share}</code> and configuration is generally stored in <code>/etc</code>. Software binaries are available in the user environment if they are placed in one of the LSB's <code>/bin</code> directories. When a program references dynamic libraries it will search for the required libraries in the LSB folders (<code>/lib</code>, <code>/usr/lib</code>). | ||
Structuring the system in this way is how NixOS obtains its key advantages over conventional Linux distributions, such as atomicity and rollback support | In NixOS however <code>/lib</code> and <code>/usr/lib</code> do not exist. Instead all system libraries, binaries, kernels, firmware and configuration files are placed in the [[Nix Package Manager:Nix Store]]. The files and directories in <code>/nix/store</code> are named by hashes of the information describing the built data. All of the files and directories placed in the Nix store are immutable. <code>/bin</code> and <code>/usr/bin</code> are almost absent: they contain only <code>/bin/sh</code> and <code>/usr/bin/env</code> respectively, to provide minimal compatibility with existing scripts using shebang lines. User-level environments are implemented using a large number of symbolic links to all required packages and auxiliary files. These environments are called [[Nix Package Manager: profiles]] and are stored in <code>/nix/var/nix/profiles</code>, each user having their own profiles. Structuring the system in this way is how NixOS obtains its key advantages over conventional Linux distributions, such as atomicity and rollback support. | ||
=== Usage of the Nix store === | |||
A lot of confusion for newcomers arises from the fact that configuration is stored in the read-only <code>/nix/store</code> tree along with all the installed packages. This fact makes it impossible to manually edit system configuration; all configuration changes must be performed by editing the <code>/etc/nixos/configuration.nix</code> file and executing <code>nixos-rebuild switch</code>. NixOS provides the [[NixOS Modules System|modules system]] for editing all required configurations. Users should first [https://nixos.org/nixos/options.html# check if an option] for the configuration they require already exists before attempting to manually add files or configuration via low-level NixOS features like activation scripts. | A lot of confusion for newcomers arises from the fact that configuration is stored in the read-only <code>/nix/store</code> tree along with all the installed packages. This fact makes it impossible to manually edit system configuration; all configuration changes must be performed by editing the <code>/etc/nixos/configuration.nix</code> file and executing <code>nixos-rebuild switch</code>. NixOS provides the [[NixOS Modules System|modules system]] for editing all required configurations. Users should first [https://nixos.org/nixos/options.html# check if an option] for the configuration they require already exists before attempting to manually add files or configuration via low-level NixOS features like activation scripts. | ||
| Line 182: | Line 173: | ||
=== Modules === | === Modules === | ||
The NixOS module system as defined in [[Nixpkgs]] provides the means necessary to customize the configuration of the OS. It is used to enable and customize services such as nginx, enable firmware and customize the kernel. | The NixOS module system as defined in [[Nixpkgs]] provides the means necessary to customize the configuration of the OS. It is used to enable and customize services such as nginx, enable firmware and customize the kernel. | ||
| Line 217: | Line 206: | ||
} | } | ||
</syntaxHighlight> | </syntaxHighlight> | ||
See the [https://nixos.org/nixos/manual/index.html#sec-writing-modules Modules section of the NixOS Manual] for more details. | |||
=== Generations === | === Generations === | ||