Nix 101 Course / Section 2: The Nix language
Premium

2.2 The Nix REPL as a power tool

Lesson 9 of 68 · 9:55

placeholder thumbnail

Create a free account to watch this lesson

Free account · no credit card needed

About this lesson

The Nix REPL is the fastest way to test a Nix expression before it ends up buried in a thousand line file. This Nix REPL tutorial shows how to evaluate code interactively, read documentation without opening a browser, and inspect, build and even patch packages from nixpkgs, all from one prompt.

In this video

  • Starting nix repl, evaluating expressions, and reading built-in docs with :doc and tab completion
  • Loading all of nixpkgs with nix repl --file and using tab completion as a quick package search
  • Inspecting package metadata: description, home page, license, and what the ... in the output hints at
  • Building a package with :b and dropping into its shell with :u, straight from the REPL
  • A live demo: patching GNU hello so it prints a different greeting, without editing a single file

After this lesson

You keep a REPL open next to your editor and test every idea there first, which saves you from writing Nix code that never had a chance to work.