6.1 Groups and unit configurations

In Tomloader basic entities can be either groups and unit configurations. We have already described what is a group in previous chapters. On the other hand, an unit configuration is an entity that holds the description of a single (eventually templated) systemd unit. Like the name suggests, unit configurations are declared inside unit configuration files (see Unit configuration files), inside default nodes or as children of apps in conf-dir/xdg-apps.kdl.

Both groups and unit configurations can contain systemd fields which can be combined in order to generate the final systemd unit. To generate a systemd unit you need to provide:

You cannot generate a systemd unit from a collection of groups without providing an unit configuration, and at the same time you cannot combine two unit configurations into a single unit. If you need to share fields between different unit configurations just use a group.

Tomloader follows the following passages to generate an unit from an unit configuration and a collection of groups.

  1. All the fields stored inside the groups are collected and merged into a single list of fields. If two or more groups try to modify the same field, then both changes are applied to that field in such a way that the final value does not depend by the order of those changes. If there is no way to produce a result regardless of the order, that field is marked as "undefined". See Conflicts for a precise description on how fields are merged.
  2. After merging the groups, field modifications defined in the unit configuration are applied to that merged field list. Now changes performed by the unit configuration can overwrite fields previously defined inside groups, in particular you can set a value or reset undefined fields.
  3. If there are still undefined fields then an error is issued and the unit is not generated. If not, then those fields are used to generate the final systemd unit.