Is it possible to define top-level systemd config inside a submodule?
To elaborate more on the question, let’s say you define a module that has one option which is a submodule and is responsible for defining the systemd config of one type of service. Then you have another submodule responsible for defining the systemd config of another type of service. Since systemd is top-level config, it will not be accessible inside the submodule.
Is there a way of making it accessible?
I know it is possible to just flatten the structure and define one module called instance1 and one module called instance2, but when working with many module-instances it is beneficial to create a hierarchical structure so that the config is more easily organized.
Both for mental clarity and for the possibility of bulking systemd services together. I want to have an enable-option in my module which gets inherited to the instances. The idea is that i can enable/disable multiple systemd services at a time.
However, this feature was not merged, and so “supermodules” are still a hypothetical feature, or perhaps an implementation pattern where a module forwards generic definitions from submodules to “cousin” options outside those submodules.
I think the PR stalled because it is non-trivial, yet does not add functionality that could not be expressed before.
Here’s an example of copying information from a submodule to its destination - systemd.services. Because that information is in the form of whole modules, it’d be quite a generic mechanism.
Thank you for your help! I looked into the “supermodules” idea and agree that it, if available, could be very beneficial. Currently i have found a work-around where i create a systemd service for each instance in the top-level module by using the instance-options and passing them through a “mkServiceConfig” function. However, this becomes difficult especially when having multiple submodule “layers”.