(updated )
Learning NixOS Module System
Let me try to summarise what I learnt in today’s deep dive into NixOS Module System:
config
holds the whole system config- a specific
config.a
is an option with a type - that
config.a
is declared by one and only one module - any module depending on that one can set
config.a
- its type decides how it is merged if set by several modules
- evaluating
config.a
means evaluating its merged definition. Every reference it has on other options needs to be resolved as well in the process. It’s highly recursive. - it’s because Nix is lazy that it is so efficient and convenient
- sometimes tweaking the merge strategy is necessary, for this we have properties
- some modules are imported by default, i.e. always there
- the DSL is implemented in a
module.nix
- the type system is implemented in
types.nix