Many many NixOS modules feature a
.enable boolean option that controls whether the module’s configuration will be utilized.
Some modules however have no
.enable option, and instead feature some random
mkIf condition like
mkIf cfg.extraConfig != "". I find this pretty problematic.
First of all, this hurts abstracting over modules. A utility function like
utils.enableMultiple "programs" [ "foo" "bar" ] can’t work, because maybe the
programs.bar module is “special” and depends on some random conditions to be enabled.
Second it hurts incidental module cooperation. Imagine the
zsh module worked this way, with random condition on when to apply its configuration. Imagine you write yourself a git module that just contributes to
programs.zsh.extraConfig. Oops, enabling your git module caused ZSH to get installed.
I understand if modules want to have secondary conditions that control how their config settings are defined. That makes total sense. But every module should have a top-level
.enabled option that controls at least whether any of the rest of the internal module logic is considered.