I have a question (gist linked below for the long version)
Short version: I want to define a function which returns a NixOS module as output, but I get an infinite recursion in the config section when I try to refer to the values of the arguments contained therein.
My questions:
Is this the sort of thing for which I should be sent to the Hague?
Right, I can do that much, my issue comes when trying to extract the pattern where the child elements (in the list of submodules) need to all undergo the same process, for example, if you want each child element to represent a set of systemd services, and the parent to represent a service upon which all the child services depend; or you have a signing key and a bunch of files that need to be signed by that key, etc.
My issue comes when trying to write config that refers to the options defined by parameter. Since config.${familyName} is defined by the outer closure, I think that this is confusing whatever does the module rollup, but I’m brand new to this (using it for a couple months), so I wasn’t sure if it’s impossible or I just needed to get good. It sounds like (from here and elsewhere on the internet where I have asked) to not be possible, and this individual summed it up well in the reddit post I made here, “The module system can be fairly temperamental, so I’m not sure if a pattern like this will work.”
If some passerby sees this thread and knows how to do something like this, I’d be interested, but this seems like I wandered adrift from where the module system wants you to go. I return to simpler waters.
Short version – the problem is actually quite obvious, you can’t set config = functionOf config.anything because it’s a really clear infinite recursion. It should be possible to set any key of config, and I hold some hope that there might be One Weird Trick. If I find it, I’ll update the gist. I also go into a bit more detail in a comment on the gist.