Nix (package manager)

Last updated
Nix
Initial releaseJune 15, 2003;20 years ago (2003-06-15)
Stable release
2.19.2 [1] / November 29, 2023;3 months ago (2023-11-29)
Repository
Written in C++
Platform Linux, Unix-like
Type Package management
License LGPL
Website nixos.org

Nix is a cross-platform package manager. It 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.

Contents

Package recipes for Nix are written in the purpose-built "Nix language", a declarative, purely functional, lazily evaluated, dynamically typed programming language. [2] 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". [3] New files in the Nix store are created though "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. [4]

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. [5] 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. [4] [6]

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

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

Nixpkgs

Nixpkgs is the package repository built upon the Nix package manager. According to Repology , as of March 2023 it contains more than 80,000 packages [10] and has a higher number of up-to-date packages than any other package repository. [11] Architectures supported by Nixpkgs are x86_64-linux, aarch64-linux, x86_64-darwin and aarch64-darwin. Packages for these architectures are regularly built, using a continuous integration service called Hydra, [12] and the results of these builds are uploaded to a public binary cache. [13] 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. [14] Beside packages, it also contains the source code for NixOS.

NixOS

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

See also

Related Research Articles

<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">Gentoo Linux</span> Linux distribution

Gentoo Linux is a Linux distribution built using the Portage package management system. Unlike a binary software distribution, the source code is compiled locally according to the user's preferences and is often optimized for the specific type of computer. Precompiled binaries are available for some packages. Gentoo runs on a wide variety of processors, including x86, PowerPC, SPARC, DEC Alpha, ARM, MIPS and PA-RISC.

<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.

<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 a minimal base system, configured by the user to only add what is purposely required.

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.

<span class="mw-page-title-main">Autopackage</span> Linux package management system

Autopackage is a free computer package management system aimed at making it simple to create a package that can be installed on all Linux distributions, created by Mike Hearn around 2002.

<span class="mw-page-title-main">SageMath</span> Computer algebra system

SageMath is a computer algebra system (CAS) with features covering many aspects of mathematics, including algebra, combinatorics, graph theory, group theory, differentiable manifolds, numerical analysis, number theory, calculus and statistics.

<span class="mw-page-title-main">CMake</span> Cross-platform, compiler-independent build system generator

In software development, CMake is cross-platform free and open-source software for build automation, testing, packaging and installation of software by using a compiler-independent method. CMake is not a build system itself; it generates another system's build files. It supports directory hierarchies and applications that depend on multiple libraries. It can invoke native build environments such as Make, Qt Creator, Ninja, Android Studio, Apple's Xcode, and Microsoft Visual Studio. It has minimal dependencies, requiring only a C++ compiler on its own build system.

The Environment Modules system is a tool to help users manage their Unix or Linux shell environment, by allowing groups of related environment-variable settings to be made or removed dynamically.

<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 is configured using composable modules, and relies on packages defined in the Nixpkgs project. Package recipes and configurations are written in the purpose-built "Nix language" that ships with the Nix package manager.

Alpine Linux is a Linux distribution designed to be small, simple, and secure. It uses musl, BusyBox, and OpenRC instead of the more commonly used glibc, GNU Core Utilities, and systemd. This makes Alpine one of few Linux distributions not to be based on the GNU Core Utilities.

<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">Redox (operating system)</span> Operating system written in Rust

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, and BSD. It is free and open-source software distributed under an MIT License.

<span class="mw-page-title-main">GNU Guix System</span> Rolling release distribution of the GNU operating system built around the GNU Guix package manager

GNU Guix System or Guix System 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 system upgrades which the user can rollback. It uses the GNU Shepherd init system and the Linux-libre kernel, with support of the GNU Hurd kernel under development. On February 3, 2015, the Free Software Foundation added the distribution to its list of endorsed free Linux distributions. The Guix package manager and the Guix System drew inspiration from and were based on the Nix package manager and NixOS respectively.

References

  1. "Release 2.15.2 · NixOS/Nix". GitHub.
  2. "Nix Reference Manual: Nix Language" . Retrieved 4 March 2024.
  3. "Nix Reference Manual: Nix Store". 4 March 2024.
  4. 1 2 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.
  5. Prins, Pjotr; Suresh, Jeeva; Dolstra, Eelco (22 December 2008). "Nix fixes dependency hell on all Linux distributions". Linux.com. Retrieved 11 July 2023.
  6. Dolstra, Eelco (2006). The Purely Functional Software Deployment Model (PDF) (Ph.D.). Utrecht University. Retrieved 11 July 2023.
  7. Burr, Chris; Clemencic, Marco; Couturier, Ben (2018). "Software packaging and distribution for LHCb using Nix" (PDF).
  8. Replit (2023-05-25). "Replit — Super Colliding Nix Stores: Nix Flakes for Millions of Developers". Replit Blog. Retrieved 2024-03-05.
  9. "Customize your IDX workspace | Project IDX". Google for Developers. Retrieved 2024-03-05.
  10. "Nixpkgs unstable repository information - Repology".
  11. "Repository statistics - Repology".
  12. "RFC 0046 - Platform Support Tiers". GitHub .
  13. "NixOS official binary cache".
  14. "Nixpkgs github repository". GitHub .
  15. "Nix & NixOS | Reproducible builds and deployments". nixos.org.
  16. 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.