Nix 101 Course / Section 5: Packaging real software with stdenv.mkDerivation
Premium

5.1 The build dance: from ./configure to your first mkDerivation

Lesson 30 of 68 · 9:07

placeholder thumbnail

Sign in, then buy this course to watch

Free account · no credit card needed

About this lesson

Almost every open source package installs the same way: download, unpack, ./configure, make, make install. In this lesson we build GNU hello by hand first, then let stdenv.mkDerivation do the whole ritual from a few lines of Nix. You see why the classic build dance maps directly onto Nix build phases, and why mkDerivation is the function behind nearly every package in nixpkgs.

In this video

  • The manual build dance: wget, tar, ./configure, make, make check, and why make install needs sudo on a normal system
  • What the configure step actually discovers about your machine, and how these steps got names like unpack phase and build phase
  • Building the same package with a mkDerivation call that fits in a handful of lines, with no compiler installed in your shell
  • Where the finished package lands instead of /usr/local/bin, and installing and removing it with nix profile
  • Why buildGoModule, buildRustPackage, and buildPythonPackage all stand on mkDerivation, so this one function pays off everywhere

After this lesson

You can turn a standard configure-and-make project into a real Nix package with a few lines of Nix, and you know the phase names that the rest of this section builds on.

Builds on: The derivation is a recipe (4.3)