Nix 101 Course / Section 2: The Nix language
Premium

2.10 How to import nixpkgs, and what the empty braces mean

Lesson 17 of 68 · 7:15

placeholder thumbnail

Sign in, then buy this course to watch

Free account · no credit card needed

About this lesson

Almost every real Nix expression starts the same way: importing nixpkgs, the biggest package collection in the world. But why does import <nixpkgs> {} end in a pair of empty braces? This lesson answers that question, shows the different ways to get nixpkgs onto your machine, and puts the answer to work on unfree packages.

In this video

  • Three ways to import nixpkgs: a local git checkout, the angle bracket path, and builtins.getFlake
  • What nixpkgs actually evaluates to, and why the empty attribute set has to be there
  • Passing config.allowUnfree so packages like Steam evaluate at all
  • The licensing reason nixpkgs makes unfree packages opt-in (it involves the public cache)
  • A peek at what else that configuration attribute set will do for you later, from overlays to cross-compilation

After this lesson

You know what really happens on the first line of nearly every Nix file, and you can import nixpkgs with exactly the configuration you need.

Builds on: Nix syntax: the complete tour (2.3)

Links: