2.2 Anatomy of a NixOS module: declaring options
Lesson 9 of 28 · 4:54
Up next in 5s…
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.mkOptionand 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
mkEnableOptionand 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:
- NixOS manual, modules section: https://nixos.org/manual/nixos/stable/index.html#sec-writing-modules
- NixOS manual, types: https://nixos.org/manual/nixos/stable/index.html#sec-option-types