Looks like the answer may be here: https://discourse.nixos.org/t/infinite-recursion-on-optional-import/8892/5
Namely, imports = [ foo ]
is desugared to imports = [ config._module.args.foo ]
, which means that config
results in a circular dependency. I think.