Nix (package manager)

Last updated
Nix
Original author(s) Eelco Dolstra
Initial releaseJune 15, 2003;21 years ago (2003-06-15)
Stable release
2.22.1 [1]   OOjs UI icon edit-ltr-progressive.svg / 10 May 2024;5 months ago (10 May 2024)
Repository
Written inC++, [2] Perl, [2] shell script, [2] Nix, [2] make, [2] Autoconf, [2] Rust, [2] C, [2] XML [2]   OOjs UI icon edit-ltr-progressive.svg
Platform Linux, Darwin, FreeBSD, [3] OpenBSD [4]   OOjs UI icon edit-ltr-progressive.svg
Type purely functional package manager, free and open-source software, programming language, functional programming language  OOjs UI icon edit-ltr-progressive.svg
License GNU Lesser General Public License, version 2.1 [5]   OOjs UI icon edit-ltr-progressive.svg
Website nixos.org

Nix is a cross-platform package manager for Unix-like systems, and a tool to instantiate and manage those systems, invented in 2003 [6] by Eelco Dolstra.

Contents

Approach

The Nix package manager employs a model in which software packages are each installed into unique directories with immutable contents. These directory names correspond to cryptographic hashes that take into account all dependencies of a package, including other packages managed by Nix. As a result, Nix package names are content-identifying since packages with the same name will have had the same inputs and the same build platform, and therefore the same build result. [7]

Implementation

Package recipes for Nix are written in the purpose-built "Nix language", a declarative, purely functional, lazily evaluated, dynamically typed programming language. [8] Distinguishing features of the Nix language are strings with "context", string interpolation, first-class file system paths, and "indented strings", which in combination allow concisely expressing dependencies between file system data when specifying the contents of new files.

Dependencies between files, as declared in the Nix language, are automatically tracked and persisted in the "Nix store". [9] New files in the Nix store are created through "derivations". A derivation is a persistent data structure that specifies an executable, arguments and environment variables for its invocation (see execve ), and other files to be read from the Nix store. The executable is then run in a sandbox that prohibits access to anything but the explicitly specified input files and only allows writing to the designated output path. Nix preserves dependency information in output files by scanning for the distinctive hashes used for package directory names. [7]

Automatic reference tracking ensures integrity of packages, even when they are transferred across machines. It also enables garbage collection of unused packages when no other package depends on them. At the cost of greater storage requirements, all upgrades in Nix are guaranteed to be both atomic and capable of efficient rollback. Unique directory names allow installing many packages with differing versions of shared libraries, and is claimed to eliminate so-called dependency hell. [10] This also lets multiple users safely install software on the same system without administrator privileges. As a result, the Nix package management and deployment model advertises more reliable, reproducible, and portable packages. [7] [11]

Nix has full support for Linux, macOS, and WSL, and can safely be installed side-by-side with another package manager.

Nixpkgs

Nixpkgs is the package repository built upon the Nix package manager. According to Repology , as of July 2024 it contains more than 110,000 packages [12] and has a higher number of up-to-date packages than any other package repository. [13] Architectures supported by Nixpkgs are x86_64-linux, aarch64-linux, x86_64-darwin and aarch64-darwin. Packages for these architectures are built regularly, using a continuous integration service called Hydra, [14] and the results of these builds are uploaded to a public binary cache. [15] When Nix installs a package, it checks this cache and downloads the binary package to avoid building it locally.

Nixpkgs is developed in a single Git repository on GitHub. [16] Beside packages, it also contains the source code for NixOS.

Projects using Nix

NixOS [17] is a Linux distribution that uses Nix for managing the entire system configuration, including the Linux kernel. [18]

Nix is used for software packaging and distribution in CERN's LHCb experiment. [19] Nix underlies the distributed software development platforms Replit [20] and Google IDX. [21]

Forks and alternative implementations

In 2021, a reimplementation by the name Tvix was announced, [22] with the goals of modularity, full compatibility with Nixpkgs, and improved evaluator performance. As of 2024, Tvix has an evaluator [23] and a store implementation, [24] though the authors do not consider the project yet stable or ready for use in production. [25] [ non-primary source needed ] Tvix is written primarily in Rust. [26]

In 2024, a team of volunteers released the first version of Lix, [27] [ non-primary source needed ] a fork of Nix focused on correctness and compatibility that uses the Meson build automation system. The project intends to gradually rewrite parts of the code in Rust. [27]

See also

Related Research Articles

<span class="mw-page-title-main">Slackware</span> Linux distribution (operating system)

Slackware is a Linux distribution created by Patrick Volkerding in 1993. Originally based on Softlanding Linux System (SLS), Slackware has been the basis for many other Linux distributions, most notably the first versions of SUSE Linux distributions, and is the oldest distribution that is still maintained.

<span class="mw-page-title-main">Package manager</span> Software tools for handling software packages

A package manager or package-management system is a collection of software tools that automates the process of installing, upgrading, configuring, and removing computer programs for a computer in a consistent manner.

<span class="mw-page-title-main">APT (software)</span> Free software package management system

Advanced package tool, or APT, is a free-software user interface that works with core libraries to handle the installation and removal of software on Debian and Debian-based Linux distributions. APT simplifies the process of managing software on Unix-like computer systems by automating the retrieval, configuration and installation of software packages, either from precompiled files or by compiling source code.

dpkg is the software at the base of the package management system in the free operating system Debian and its numerous derivatives. dpkg is used to install, remove, and provide information about .deb packages.

<span class="mw-page-title-main">Portage (software)</span> Gentoo package management system

Portage is a package management system originally created for and used by Gentoo Linux and also by ChromeOS, Calculate, Sabayon, and Funtoo Linux among others. Portage is based on the concept of ports collections. Gentoo is sometimes referred to as a meta-distribution due to the extreme flexibility of Portage, which makes it operating-system-independent. The Gentoo/Alt project was concerned with using Portage to manage other operating systems, such as BSDs, macOS and Solaris. The most notable of these implementations is the Gentoo/FreeBSD project.

<span class="mw-page-title-main">Arch Linux</span> Rolling release distribution of Linux

Arch Linux is an independently developed x86-64 general-purpose Linux distribution that strives to provide the latest stable versions of most software by following a rolling-release model. The default installation is intentionally minimal so that users can add only the packages they require.

Dependency hell is a colloquial term for the frustration of some software users who have installed software packages which have dependencies on specific versions of other software packages.

AppImage is an open-source format for distributing portable software on Linux. It aims to allow the installation of binary software independently of specific Linux distributions, a concept often referred to as upstream packaging. As a result, one AppImage can be installed and run across Ubuntu, Arch Linux, and Red Hat Enterprise Linux without needing to use different files. It aims to be a format that is self-contained, rootless, and independent of the underlying Linux distribution.

<span class="mw-page-title-main">RPM Package Manager</span> Package management system

RPM Package Manager (RPM) is a free and open-source package management system. The name RPM refers to the .rpm file format and the package manager program itself. RPM was intended primarily for Linux distributions; the file format is the baseline package format of the Linux Standard Base.

NixOS is a free and open source Linux distribution based on the Nix package manager. NixOS uses an immutable design and an atomic update model. Its use of a declarative configuration system allows reproducibility and portability.

<span class="mw-page-title-main">Homebrew (package manager)</span> macOS CLI package manager in Ruby

Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple's operating system, macOS, as well as Linux. The name is intended to suggest the idea of building software on the Mac depending on the user's taste. Originally written by Max Howell, the package manager has gained popularity in the Ruby on Rails community and earned praise for its extensibility. Homebrew has been recommended for its ease of use as well as its integration into the command-line interface. Homebrew is a member of the Open Source Collective, and is run entirely by unpaid volunteers.

<span class="mw-page-title-main">Leafpad</span> Lightweight text editor

Leafpad is a free and open-source graphical text editor for Linux, Berkeley Software Distribution (BSD), and Maemo that is similar to the Microsoft Windows program Notepad. Created with the focus of being a lightweight text editor with minimal dependencies, it is designed to be simple-to-use and easy-to-compile.

<span class="mw-page-title-main">GNU Guix</span> Purely functional package manager for the GNU system

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 default package manager of the GNU Guix System distribution.

<span class="mw-page-title-main">Devuan</span> Linux distribution based on Debian

Devuan is a fork of the Debian Linux distribution that uses sysvinit, runit or OpenRC instead of systemd. Devuan aims to avoid "lock-in" by projects like systemd and aims to maintain compatibility with other init systems to avoid detaching Linux from other Unix systems.

<span class="mw-page-title-main">Snap (software)</span> Software deployment system for Linux by Canonical

Snap is a software packaging and deployment system developed by Canonical for operating systems that use the Linux kernel and the systemd init system. The packages, called snaps, and the tool for using them, snapd, work across a range of Linux distributions and allow upstream software developers to distribute their applications directly to users. Snaps are self-contained applications running in a sandbox with mediated access to the host system. Snap was originally released for cloud applications but was later ported to also work for Internet of Things devices and desktop applications.

<span class="mw-page-title-main">Flatpak</span> Linux software deployment utility

Flatpak is a utility for software deployment and package management for Linux. It is advertised as offering a sandbox environment in which users can run application software in isolation from the rest of the system. Flatpak was known as xdg-app until 2016.

<span class="mw-page-title-main">Redox (operating system)</span> Operating system written with the Rust programming language

Redox is a Unix-like microkernel operating system written in the programming language Rust, which has a focus on safety, stability, and performance. Redox aims to be secure, usable, and free. Redox is inspired by prior kernels and operating systems, such as SeL4, MINIX, Plan 9, BSD, and Linux. It is free and open-source software distributed under an MIT License.

<span class="mw-page-title-main">AlmaLinux</span> Linux distribution based on Red Hat Enterprise Linux

AlmaLinux is a free and open source Linux distribution, developed by the AlmaLinux OS Foundation, a 501(c) organization, to provide a community-supported, production-grade enterprise operating system that is binary-compatible with Red Hat Enterprise Linux (RHEL). The name of the distribution comes from the word "alma", meaning "soul" in Spanish and other Latin languages. It was chosen to be a homage to the Linux community.

References

  1. "Release 2.22.1". 10 May 2024. Retrieved 17 May 2024.
  2. 1 2 3 4 5 6 7 8 9 "The Nix Open Source Project on Open Hub: Languages Page". Open Hub. Retrieved 18 May 2024.
  3. "NixBSD".
  4. "OpenBSD Ports Readme: port sysutils/nix".
  5. "nix/COPYING at master". 26 April 2006. Retrieved 18 May 2024.
  6. Dolstra, Eelco (2003). "Integrating Software Construction and Software Deployment" (PDF). Software Configuration Management. Lecture Notes in Computer Science. Vol. 2649. pp. 102–117. doi:10.1007/3-540-39195-9_8. ISBN   978-3-540-14036-8. Archived from the original (PDF) on 2019-04-21.
  7. 1 2 3 Dolstra, Eelco; de Jonge, Merijn; Visser, Eelco (November 2004). "Nix: A Safe and Policy-Free System for Software Deployment" (PDF). LISA '04: Proceedings of the 18th USENIX Conference on System Administration. pp. 79–92. Retrieved 11 July 2023.
  8. "Nix Reference Manual: Nix Language" . Retrieved 4 March 2024.
  9. "Nix Reference Manual: Nix Store". 4 March 2024.
  10. Prins, Pjotr; Suresh, Jeeva; Dolstra, Eelco (22 December 2008). "Nix fixes dependency hell on all Linux distributions". Linux.com. Retrieved 11 July 2023.
  11. Dolstra, Eelco (2006). The Purely Functional Software Deployment Model (PDF) (Ph.D.). Utrecht University. Retrieved 11 July 2023.
  12. "Nixpkgs unstable repository information - Repology". Archived from the original on 2018-06-03.
  13. "Repository statistics - Repology".
  14. "RFC 0046 - Platform Support Tiers". GitHub .
  15. "NixOS official binary cache".
  16. "Nixpkgs github repository". GitHub .
  17. "Nix & NixOS | Reproducible builds and deployments". nixos.org.
  18. Dolstra, Eelco; Löh, Andres; Pierron, Nicolas (September 2008). NixOS: A Purely Functional Linux Distribution (PDF). ICFP 2008: 13th ACM SIGPLAN International Conference on Functional Programming. pp. 367–378.
  19. Burr, Chris; Clemencic, Marco; Couturier, Ben (2018). "Software packaging and distribution for LHCb using Nix" (PDF).
  20. Replit (2023-05-25). "Replit — Super Colliding Nix Stores: Nix Flakes for Millions of Developers". Replit Blog. Retrieved 2024-03-05.
  21. "Customize your IDX workspace | Project IDX". Google for Developers. Retrieved 2024-03-05.
  22. "TVL's blog: Tvix: We are rewriting Nix". tvl.fyi. Retrieved 2024-05-19.
  23. "TVL's blog: Tvix Status - September '22". tvl.fyi. Retrieved 2024-05-19.
  24. "TVL's blog: Tvix Status - February '24". tvl.fyi. Retrieved 2024-05-19.
  25. tvlfyi/tvix, The Virus Lounge, 2024-05-18, retrieved 2024-05-19
  26. "tvix - depot - Sourcegraph". cs.tvl.fyi. Retrieved 2024-05-19.
  27. 1 2 "Lix | About Lix". lix.systems. Retrieved 2024-05-19.