Nix 101 Course / Section 9: Flakes
Premium

9.1 What flakes are and why they exist

Lesson 59 of 68 · 11:28

placeholder thumbnail

Sign in, then buy this course to watch

Free account · no credit card needed

Video chapters

  1. 0:00 Introduction to Flakes
  2. 1:14 Why Flakes Exist
  3. 3:16 Flake Features and User Experience
  4. 6:31 Flake History and Community Debate
Transcript

Introduction to Flakes

0:00 So finally, we're at the Flakes section. Many people feel like, so why do you do this so late in the training, or do we really have to learn the old commands? Because there's the new ones already. I hope that you have seen that now 99% of the features that you want to have from Nix and NixOS have nothing to do with Flakes. And Flakes are just the shim that you can throw on top, as we will see in the rest of this section here right now.

0:33 So the idea is now to discuss why Flakes even exist. What actual problem do they solve? How do you use them in practice? We also have some anti-patterns prepared, because many people just copy and paste Flakes that are not really advantages, let's say. And then we'll also discuss the trade-offs, because there are very clear trade-offs on this controversial feature, where sometimes it's disadvantages to use Flakes, frankly. And we will exactly explain why.

1:05 So after this section, you will go away with knowledge how to use Flakes correctly, what to do, what not to do, and also where do Flakes simply not

The full transcript comes with the lesson.

About this lesson

Nix flakes are the most argued about feature in the ecosystem, and this lesson opens the flakes section with the question forum threads never answer: what problem do flakes actually solve? You learn where evaluation caching, the flake registry, built-in pinning and the new nix CLI come from, and why flakes are still marked experimental years after their 2019 debut. This is the context that makes every flakes tutorial afterwards click.

In this video

  • The one thing Nix could never cache before flakes, and which features (NIX_PATH, builtins.currentSystem) had to be forbidden to get it
  • What replaced channels: the registry behind nix shell nixpkgs#nodejs
  • Mixing packages from two different nixpkgs revisions in a single command, something the old CLI could not do
  • Running a tool straight from a GitHub repository with nix run, no checkout needed
  • The RFC history: why flakes are still not enabled by default, told by someone who asked Eelco about it over lunch at NixCon

After this lesson

You know exactly what flakes add on top of plain Nix, what they take away, and why the community is split. Every design decision in the following lessons will make sense.