NixOS 101 Course / Section 2: NixOS configuration and the module system
Premium

2.5 Who set this? Inspecting a live NixOS configuration in the REPL

Lesson 12 of 28 · 4:37

placeholder thumbnail

Sign in, then buy this course to watch

Free account · no credit card needed

Video chapters

  1. 0:00 Inspecting NixOS config in the REPL
  2. 1:14 Tracing SSH and firewall settings
  3. 2:45 Exploring system packages and option origins
Transcript

Inspecting NixOS config in the REPL

0:00 In the last two videos we've been playing with the NixOS modules library like as a dry exercise and now let's apply that knowledge that we just got on our real-life NixOS configuration. So for example on our configuration here we opened configuration.nix and then we added SSH for example and configured it nicely and the question is now what other settings do we have here?

0:31 Of course we can always kind of look at the SSHD configuration and then we see all the values here kind of encoded in the way that SSHD configures them but maybe we have a very complicated NixOS configuration and multiple files set this. So what we can do is we can open the REPL and as we have a flake file for this configuration we can say load flake and then what we get is nixosConfigurations and we can go to mynixos and then access the config object and then say services.openssh.

1:12 And the cool thing is we can tap through this so this is another way to find out what other configuration parameters are there in addition to search.nixos.org.

The full transcript comes with the lesson.

About this lesson

In a large NixOS configuration spread over many files it can happen values show up that you never set yourself. This lesson loads a real NixOS flake into the Nix REPL, browses the evaluated configuration, and traces values back to the module that set them.

In this video

  • Loading your system flake in the REPL and tab completing through all of its settings
  • Defaults you didn't know about, like a firewall port that opened without you asking
  • Finding the exact file that set a value, without grep
  • Seeing which modules contribute to the list of installed packages

After this lesson

When a setting in your system surprises you, you can find its source in seconds instead of searching through repositories.

Builds on: Exploring the NixOS module system in the REPL (2.3)