Skills2026年5月5日·1 分钟阅读

Nix — Reproducible Package Manager and Build System

A purely functional package manager that ensures reproducible builds and atomic upgrades across Linux and macOS, powering NixOS and developer environments.

Agent 就绪

这个资产可以被 Agent 直接读取和安装

TokRepo 同时提供通用 CLI 命令、安装契约、metadata JSON、按适配器生成的安装计划和原始内容链接,方便 Agent 判断适配度、风险和下一步动作。

Needs Confirmation · 64/100策略:需确认
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Nix
通用 CLI 安装命令
npx tokrepo install 197d54ef-48c0-11f1-9bc6-00163e2b0d79

Introduction

Nix is a purely functional package manager where each package is built in isolation from a precise description of its dependencies. This model guarantees reproducible builds, atomic upgrades and rollbacks, and the ability to run multiple versions of any package side by side without conflicts.

What Nix Does

  • Builds and installs packages in isolation under /nix/store with content-addressed paths
  • Provides atomic upgrades and instant rollbacks for system and user profiles
  • Manages per-project development environments via nix-shell or nix develop
  • Powers NixOS, a Linux distribution where the entire system is declared in a single configuration file
  • Caches and shares build results through binary substitution from remote caches

Architecture Overview

Every Nix package is defined by a derivation — a pure function from inputs (source, dependencies, build script) to a store path. The Nix store (/nix/store) holds all build outputs, each identified by a hash of its inputs. A build daemon executes derivations in sandboxed environments. Profiles are symlink trees pointing into the store, making switches atomic.

Self-Hosting & Configuration

  • Install with the official installer on any Linux distribution or macOS
  • Configure in /etc/nix/nix.conf or ~/.config/nix/nix.conf for substituters and features
  • Enable Flakes with experimental-features = nix-command flakes for the modern CLI
  • Use binary caches (cache.nixos.org or custom) to avoid rebuilding from source
  • Declare project dependencies in a flake.nix for portable reproducible environments

Key Features

  • Content-addressed store ensures bit-for-bit reproducible builds
  • Atomic upgrades with instant rollback to any previous generation
  • Multiple package versions coexist without conflicts or containers
  • Flakes provide hermetic, lockfile-based project definitions
  • Cross-compilation support for dozens of target platforms

Comparison with Similar Tools

  • Homebrew — simpler to start; no reproducibility guarantees or rollback support
  • apt/dnf — distribution-native; global state makes version conflicts common
  • Guix — similar functional model using Guile Scheme instead of the Nix language
  • Docker — provides isolation via containers; heavier weight than Nix shells for development

FAQ

Q: Do I need NixOS to use Nix? A: No. Nix runs as a package manager on any Linux distribution and on macOS.

Q: What are Flakes? A: Flakes are a newer interface for defining Nix projects with a lockfile for pinned dependencies, making builds fully reproducible across machines.

Q: Does Nix work on macOS? A: Yes. Nix supports macOS with a dedicated installer and the nix-darwin module for system configuration.

Q: How much disk space does the Nix store use? A: It varies. Run nix-collect-garbage -d to remove unused store paths and reclaim space.

Sources

讨论

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

相关资产