NixOS: Difference between revisions

Nanucq (talk | contribs)
No edit summary
DHCP (talk | contribs)
update links (mostly changed wikipedia.org to interwiki links); Note: the interwiki links are not labeled with an "arrow" denoting external website. ArchWiki enables that and it really helps distinguishing links. This may be something subjective, but i consider it worth enabling in NixOS wiki!
Line 6: Line 6:


<!--T:2-->
<!--T:2-->
[https://nixos.org/ NixOS] is a Linux distribution based on the [[Special:MyLanguage/Nix|Nix]] package manager and build system. It supports [https://en.wikipedia.org/wiki/Declarative_programming declarative] system-wide [https://en.wikipedia.org/wiki/Configuration_management configuration management] as well as [https://en.wikipedia.org/wiki/Atomicity_(database_systems) atomic] upgrades and rollbacks, although it can additionally support [https://en.wikipedia.org/wiki/Imperative_programming imperative] package and user management. In NixOS, all components of the distribution &mdash; including the [https://en.wikipedia.org/wiki/Linux_kernel kernel], installed [https://en.wikipedia.org/wiki/Package_manager packages] and system configuration files &mdash; are built by [[Special:MyLanguage/Nix|Nix]] from [[Wikipedia:Pure function|pure functions]] called [[Special:MyLanguage/Nix Expression Language|Nix expressions]].
[https://nixos.org/ NixOS] is a Linux distribution based on the [[Special:MyLanguage/Nix|Nix]] package manager and build system. It supports [[Wikipedia:Declarative programming|declarative]] system-wide [[Wikipedia:Configuration management|configuration management]] as well as [[Wikipedia:Atomicity (database_systems)|atomic]] upgrades and rollbacks, although it can additionally support [[Wikipedia:Imperative programming|imperative]] package and user management. In NixOS, all components of the distribution &mdash; including the [[Wikipedia:Linux kernel|kernel]], installed [[Wikipedia:Package manager|packages]] and system configuration files &mdash; are built by [[Special:MyLanguage/Nix|Nix]] from [[Wikipedia:Pure function|pure functions]] called [[Special:MyLanguage/Nix (language)|Nix expressions]].


<!--T:3-->
<!--T:3-->
Since Nix uses [https://en.wikipedia.org/wiki/Executable binary] caching, this provides a unique compromise between the binary-oriented approach used by distributions such as Debian and the [https://en.wikipedia.org/wiki/Source_code source]-oriented approach used by distributions such as Gentoo. Binaries can be used for standard components, and custom-built packages and modules can be used automatically when a pre-built binary is not available.
Since Nix uses [[Wikipedia:Executable|binary]] caching, this provides a unique compromise between the binary-oriented approach used by distributions such as Debian and the [[Wikipedia:Source code|source]]-oriented approach used by distributions such as Gentoo. Binaries can be used for standard components, and custom-built packages and modules can be used automatically when a pre-built binary is not available.


<!--T:4-->
<!--T:4-->
Stable NixOS releases are delivered twice a year (around the end of May and the end of November). NixOS was created by [https://edolstra.github.io/ Eelco Dolstra] and [https://en.wikipedia.org/wiki/Armijn_Hemel Armijn Hemel], and initially released in 2003. It is community developed and maintained under the stewardship of the [[Special:MyLanguage/Nix_Community#NixOS_Foundation|NixOS Foundation]].
Stable NixOS releases are delivered twice a year (around the end of May and the end of November). NixOS was created by [https://edolstra.github.io/ Eelco Dolstra] and [[Wikipedia:Armijn Hemel|Armijn Hemel]], and initially released in 2003. It is community developed and maintained under the stewardship of the [[Special:MyLanguage/Nix_Community#NixOS_Foundation|NixOS Foundation]].


== Installation == <!--T:5-->
== Installation == <!--T:5-->
Line 118: Line 118:


<!--T:36-->
<!--T:36-->
For more information on using and configuring nix channels, refer to [[Special:MyLanguage/channel branches|channel branches]].
For more information on using and configuring nix channels, refer to [[Special:MyLanguage/Channel branches|channel branches]].


== Internals == <!--T:37-->
== Internals == <!--T:37-->
Line 128: Line 128:


<!--T:40-->
<!--T:40-->
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>).
The main difference between NixOS and other Linux distributions is that NixOS does not follow the [[Wikipedia: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>).


<!--T:41-->
<!--T:41-->
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 [[Special:MyLanguage/Nix#Nix store|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 [[Special:MyLanguage/Nix#Profiles|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.
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 [[Special:MyLanguage/Nix (package_manager)#Nix store|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 [[Special:MyLanguage/Nix#Profiles|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 === <!--T:42-->
=== Usage of the Nix store === <!--T:42-->
Line 179: Line 179:


<!--T:49-->
<!--T:49-->
See the [https://nixos.org/nixos/manual/index.html#sec-writing-modules Modules section of the NixOS Manual] for more details.
See the [https://nixos.org/manual/nixos/stable/index.html#sec-writing-modules Modules section of the NixOS Manual] for more details.


=== Generations === <!--T:50-->
=== Generations === <!--T:50-->