I still do not really understand why it behaved this way ?
I tried to explain why it works like this in Best resources for learning about the NixOS module system? - #3 by teto
I have the feeling that the mkIf expression is still evaluated even if the flag is set, right
right.
So what can be done:
- you may set
_module.check = false;
, then it won’t complain about this kind of problems. It is bad, because when you do typos in option names, it won’t detect those typos - you may add an explicit variable load. For example, add to each module:
let home-manager = builtins.getEnv "IS_HOME_MANAGER_EVAL" == "yes"; in
This way resolvinghome-manager
doesn’t require module system eval, so it won’t cause infinite recursion. Now all you have to do isexport IS_HOME_MANAGER_EVAL=yes
before home-manager rebuilds. - best is to split system config and home configs and don’t try to mix that
- or mix those correctly. I’ve seen that @Infinisil had merged those nicely in GitHub - infinisil/system: My system configuration. For example, here is how system service and
home.packages
are intermixed. Check this file for how to add home-manager module.