Jump to content

Nix (package manager)

From Wikipedia, the free encyclopedia
(Redirected from Nixpkgs)
Nix
Original author(s)Eelco Dolstra
Initial releaseJune 15, 2003; 21 years ago (2003-06-15)
Stable release
2.22.1[1] Edit this on Wikidata / 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] Edit this on Wikidata
PlatformLinux, other Unix-like
Typepurely functional package manager, free and open-source software, programming language Edit this on Wikidata
LicenseGNU Lesser General Public License, version 2.1[3] Edit this on Wikidata
Websitenixos.org

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

Approach

[edit]

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

Implementation

[edit]

Package recipes for Nix are written in the purpose-built "Nix language", a declarative, purely functional, lazily evaluated, dynamically typed programming language.[6] 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".[7] 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.[5]

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.[8] 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.[5][9]

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

Nixpkgs

[edit]

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[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 built regularly, 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.

Projects using Nix

[edit]

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

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

Forks and alternative implementations

[edit]

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

In 2024, a team of volunteers released the first version of Lix,[25][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.[25]

See also

[edit]
  • GNU Guix: another declarative package manager, and early clone of Nix, using GNU Guile for configuration and customization
  • Maak: a build automation utility similar to make, and early precursor to Nix
  • Runbook automation

References

[edit]
  1. ^ "Release 2.22.1". 10 May 2024. Retrieved 17 May 2024.
  2. ^ a b c d e f g h i "The Nix Open Source Project on Open Hub: Languages Page". Open Hub. Retrieved 18 May 2024.
  3. ^ "nix/COPYING at master". 26 April 2006. Retrieved 18 May 2024.
  4. ^ 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.
  5. ^ a b c 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.
  6. ^ "Nix Reference Manual: Nix Language". Retrieved 4 March 2024.
  7. ^ "Nix Reference Manual: Nix Store". 4 March 2024.
  8. ^ Prins, Pjotr; Suresh, Jeeva; Dolstra, Eelco (22 December 2008). "Nix fixes dependency hell on all Linux distributions". Linux.com. Retrieved 11 July 2023.
  9. ^ Dolstra, Eelco (2006). The Purely Functional Software Deployment Model (PDF) (Ph.D.). Utrecht University. Retrieved 11 July 2023.
  10. ^ "Nixpkgs unstable repository information - Repology". Archived from the original on 2018-06-03.
  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.
  17. ^ Burr, Chris; Clemencic, Marco; Couturier, Ben (2018). "Software packaging and distribution for LHCb using Nix" (PDF).
  18. ^ Replit (2023-05-25). "Replit — Super Colliding Nix Stores: Nix Flakes for Millions of Developers". Replit Blog. Retrieved 2024-03-05.
  19. ^ "Customize your IDX workspace | Project IDX". Google for Developers. Retrieved 2024-03-05.
  20. ^ "TVL's blog: Tvix: We are rewriting Nix". tvl.fyi. Retrieved 2024-05-19.
  21. ^ "TVL's blog: Tvix Status - September '22". tvl.fyi. Retrieved 2024-05-19.
  22. ^ "TVL's blog: Tvix Status - February '24". tvl.fyi. Retrieved 2024-05-19.
  23. ^ tvlfyi/tvix, The Virus Lounge, 2024-05-18, retrieved 2024-05-19
  24. ^ "tvix - depot - Sourcegraph". cs.tvl.fyi. Retrieved 2024-05-19.
  25. ^ a b "Lix | About Lix". lix.systems. Retrieved 2024-05-19.
[edit]