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

2.2 Anatomy of a NixOS module: declaring options

Lesson 9 of 28 · 4:54

placeholder thumbnail

Sign in, then buy this course to watch

Free account · no credit card needed

About this lesson

Using options is one half of NixOS. Declaring your own is the other half, and it is how services.myservice.enable = true gets to exist. This lesson shows the two parts of a module that declares options, the fields every option has, and the helpers that save you typing.

In this video

  • The two parts of a module that offers options and what they do
  • lib.mkOption and its fields: type, default, example, and description
  • Where option types come from, and the manual chapter worth reading once in your life
  • How your descriptions turn into documentation, also for company internal modules
  • mkEnableOption and other shorthands

After this lesson

You can read the option declarations in any nixpkgs module, and you are ready to write your own in the next lessons.

Links: