What is Nix?

There are several interrelated systems with “Nix” in their names.

Nix is a language

The Nix language The documentation for Nix, the build tool and its language. is a lazy lambda calculus, a minimal programming language that was designed expressly for configuring Nix packages (see below). Since it is a lazy lambda calculus, it can’t really do side effects; for the most part, all it can do is evaluate expressions to a value. However, since it was designed for configuring packages, it has a few built-in features for the limited side effects required for that purpose.

We list it first because Nix the language is pervasive throughout the other uses of the name Nix: it is the language the package configurations are written in; it is the language your NixOS configuration is written in and you may use it on the command line, especially with NixOS and NixOps, where commands may be Nix expressions. There is a REPL available for the Nix language.

Nix is a package manager

The Nix package manager can be used on many operating systems. Unlike most comparable systems such as apt, there is no distinction between packages that you get from the central host and packages that you define and build yourself.

Nix is a build tool

The system focuses on atomic, reproducible builds. Builds are reproducible because each package’s dependencies are explicitly declared and bundled so that everything the package needs is installed when you install the package. So, if you can build a Nix package on one machine, you can also build it on another machine. Builds are atomic in that installing or updating a package can’t break other packages because Nix does not overwrite the dependencies for any other package on the machine.

Nix comes with many packages

Like other major package managers such as apt, homebrew, etc., The documentation for Nixpkgs, the set of packages that build with the Nix tool. Nix has a huge collection of packages. Just about any open source Linux program you can think of can be installed with Nix. The package collection is called nixpkgs, which is the name of the GitHub repository github.com/nixos/nixpkgs is where all the package magic happens. It accepts a lot of contributions through pull requests; if there is a new package you’d like to see in Nix, you can submit it. in which it is all maintained.

NixOS is an operating system

NixOS is, The documentation for NixOS, the operating system build from Nix packages. at its simplest, the package manager – but now it builds your Linux kernel, the whole operating system, and all its dependencies and packages. The complete list of configuration options, to use for reference when you customize your NixOS configuration.

One of the things we love most about it, especially after being burned by some “security updates” on other operating systems that went badly wrong, is that you can always roll back to an earlier configuration of your NixOS machine because no build overwrites earlier builds.

Another thing we love is how easy provisioning a new machine can be, because you can specify packages to install as it builds your OS right in your configuration file – both standard programs from the nixpkgs repository, as well as your own applications. This is especially awesome for servers, although we both use NixOS on our home machines as well.

Join Type Classes for courses and projects to get you started and make you an expert in FP with Haskell.