1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 06:31:14 +02:00
nix/doc/manual/src/architecture/architecture.md
Valentin Gagarin 7c3bca1372 revert to build plans in top-level overview
do not introduce build tasks yet, that is the next level of detail.
2022-08-04 12:37:47 +02:00

2.6 KiB

Architecture

This chapter describes how Nix works. It should help users understand why Nix behaves as it does, and it should help developers understand how to modify Nix and how to write similar tools.

Overview

Nix consists of hierarchical layers.

+-----------------------------------------------------------------+
| Nix                                                             |
|                  [ commmand line interface ]------,             |
|                               |                   |             |
|                           evaluates               |             |
|                               |                manages          |
|                               V                   |             |
|                  [ configuration language  ]      |             |
|                               |                   |             |
| +-----------------------------|-------------------V-----------+ |
| | store                  evaluates to                         | |
| |                             |                               | |
| |             referenced by   V       builds                  | |
| |  [ build input ] ---> [ build plan ] ---> [ build result ]  | |
| |                                                             | |
| +-------------------------------------------------------------+ |
+-----------------------------------------------------------------+

At the top is the command line interface, translating from invocations of Nix executables to interactions with the underlying layers.

Below that is the Nix expression language, a purely functional configuration language. It is used to compose expressions which ultimately evaluate to self-contained build plans, used to derive build results from referenced build inputs.

The command line and Nix language are what users interact with most.

::: {.note} The Nix language itself does not have a notion of packages or configurations. As far as we are concerned here, the inputs and results of a derivation are just data. In practice this amounts to a set of files in a file system. :::

Underlying these is the Nix store, a mechanism to keep track of build plans, data, and references between them. It can also execute build plans to produce new data.