Scripts2026年5月26日·1 分钟阅读

Nixpkgs — The Largest Reproducible Package Collection

A community-driven repository of over 100,000 packages for the Nix package manager, providing reproducible builds and declarative system configuration across Linux and macOS.

Agent 就绪

先审查再安装

这个资产需要先审查。复制的指令会要求 Agent dry-run、列出写入项,确认后再继续。

Needs Confirmation · 64/100策略:需确认
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Nixpkgs Overview
先审查命令
npx -y tokrepo@latest install 74276a46-58ba-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run,确认写入项后再运行此命令。

Introduction

Nixpkgs is the package collection for the Nix package manager, maintained by thousands of contributors worldwide. It provides a single repository of package definitions (called derivations) that produce bit-for-bit reproducible builds. Every package build is isolated in a sandbox, ensuring that dependency graphs are explicit and that builds work the same way on any machine.

What Nixpkgs Does

  • Defines over 100,000 packages in a single monorepo using the Nix expression language
  • Produces reproducible builds by pinning every dependency down to the compiler and libc version
  • Supports Linux (x86_64, aarch64) and macOS (Intel and Apple Silicon) from one source tree
  • Provides NixOS modules for declarative system configuration (services, users, networking)
  • Enables atomic upgrades and rollbacks so a bad update never leaves your system broken

Architecture Overview

Nixpkgs is a large Git repository of Nix expressions. Each package is a function that declares its build inputs, build script, and metadata. The Nix evaluator reads these expressions, computes a hash of all inputs (source tarballs, compilers, flags), and stores the result under /nix/store/<hash>-<name>. Because the path encodes the full dependency tree, multiple versions of the same library coexist without conflict. Hydra, the Nix CI system, pre-builds binary caches so most users download substitutes instead of compiling from source.

Self-Hosting & Configuration

  • Clone the repo: git clone https://github.com/NixOS/nixpkgs.git
  • Pin a specific commit in your project with flake.lock or niv for reproducibility
  • Override packages using overlays to patch or change build flags
  • Set up a private binary cache with nix-serve or Cachix to share builds across your team
  • Use nixos-rebuild switch to apply system-level changes on NixOS machines

Key Features

  • Bit-for-bit reproducible builds backed by content-addressed store paths
  • Atomic upgrades and rollbacks via symlink switching with no partial installs
  • Cross-compilation support for embedded and foreign architectures out of the box
  • Flakes provide hermetic project-level dependency management with a lock file
  • One of the fastest-moving open-source repos with thousands of package updates per week

Comparison with Similar Tools

  • Homebrew — user-friendly on macOS but not reproducible; Nixpkgs guarantees identical outputs across machines
  • apt / dnf — distribution-specific; Nixpkgs works across Linux distros and macOS from one source
  • Guix — similar concept using Guile Scheme; Nixpkgs has a much larger package set and community
  • Docker — isolates at the container level; Nix isolates at the package level, producing smaller closures
  • Conda — focused on Python/data-science; Nixpkgs covers the full OS stack including kernels and services

FAQ

Q: Do I need to use NixOS to benefit from Nixpkgs? A: No. You can install the Nix package manager on any Linux distro or macOS and use Nixpkgs packages alongside your system package manager.

Q: How do I update all my packages? A: Run nix flake update (if using flakes) or nix-channel --update && nix-env -u to pull the latest package definitions and upgrade.

Q: Is Nixpkgs suitable for production servers? A: Yes. NixOS is used in production by companies like Determinate Systems and Tweag for its reproducibility and rollback guarantees.

Q: How do I contribute a new package? A: Fork the nixpkgs repository, add your package derivation under the appropriate directory, and open a pull request. The Nixpkgs manual documents the conventions.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产