Nix is a build tool, language, package manager, and operating system to reproducibly declare how software should be built.

It’s bizarre.

The language itself feels like the spirit of a Haskell derivative, bound to the body of the unholy spawn of JSON and YAML. Lazy evaluation, pure functions, all that jazz, but the top level return type is almost always an attribute set used by another bit of code to create derivations.

I’m so entirely sold on some parts of this experiment, and others feel wildly off. As a way to manage my various personal machines, it’s a godsend. New machines can be brought up or restored almost immediately, configurations are as reproducible as I’ve found, and package management is fast. But I don’t know if I’d ever actually suggest that my team work in Nix. This isn’t because of the obscurity of the language; it’s mostly because it’s so difficult to know how to do what you want. Documentation isn’t just lacking, it’s split up across many different resources, and none of them feel complete, especially when you have to dive into the deeper underbelly of creating your own derivations. But this would be less of an issue if you weren’t mostly dealing with such high level abstractions.

What is a Derivation?

derivation is a special function in Nix that defines a thing to actually do. It’s where your real world code gets executed and can depend on other derivations and use what they built. The outputs of these derivations then get put in places on your computer that are actually useful to you.

For example:

  • I want to build dmux.
  • I make a derivation that depends on the rust toolchain.
  • The output of the rust toolchain derivation is used to build my dmux derivation
  • The output of my dmux derivation is a dmux binary that I can then put in my PATH
  • profit

Flakes

Flakes are a fairly controversial, newer feature of nix that provide explicit locked versioning for inputs, and a standard interface for other nix projects, like the nix CLI, to interact with. They’re fairly controversial.

NOTE

This page is still under construction!