Check out FlakeHub — the best place to discover and publish Nix flakes, from Determinate Systems.

We use a single, first-party analytics cookie to focus our limited time and energy on the most important documentation. Check out our privacy policy .

Declarative programming

A programming paradigm used by Nix that emphasizes what you want to build rather than how things are built

Concepts / Declarative programming

We recommend starting with the Nix quick start and consulting concept docs primarily for clarification. Feel free to click x to the right to disable this notification on all concept docs.

In declarative programming a user instructs the computer what to do, not how to do it.

The result of this is that often a final system is described as it should exist. A management program (in this case Nix) can then construct a path towards the final output and do the necessary steps in the required order, without a user having to worry about what exactly is happening and when.

Nix follows declarative principles in the way that package definitions (or derivations) are constructed with some minor exceptions.

Under the hood, some parts of packages still have to be written imperatively, but by wrapping these parts in declarative layers, users of the upper layers don’t have to be aware of what is happening below the surface.

Essentially: one user can solve a problem once, and many people can then benefit from that solution without needing to know how exactly it works (unless they want to).


Was this page helpful?