Nix (Package Manager) Knowledge

Kip Landergren

(Updated: )

Contents

Overview

Nix is a suite of tools for building packages in a declarative and reproducible way.

A package is a collection of software, which may contain:

Creating working versions of these packages involve solving two main problems:

Maintainers of C-based packages have consistently reached for autotools and make as preferred solutions. When you run ./configure, autoconf checks your system for the presence, location, and information of dependencies, including the compiler. When you run make that information is marshaled to actually execute the build and compile source code.

What invariably happens is one (or many!) of:

And all of these are repeated for each environment (my machine, my coworker’s, production...) that wants to use the package.

Let’s imagine you overcome all of these issues. One still has to contend with the particularly pernicious problem of having two packages A and B that each declare a dependency on different versions of package C. How should your system be configured such that both can exist?

Nix aims to solve these problems (and more) by providing an ergonomic harness around existing packages’ build processes.

This harness consists of:

The additional architectural benefit here is that existing software’s build processes remain untouched: the work is with the Nix package maintainers to create the package expressions.

The end result are packages with:

Core Idea

Nix the language is about functional programming with a build system.

It, and its standard library, are specifically created to:

Nix the software is about then executing that build graph to produce a package in a reproducible way.

It accomplishes this through:

By knowing the path ahead of time (it is based on the hash of its inputs) Nix provides a means to transparently reuse previously built portions of the build graph without recompilation.

Key Concepts