This makes the systemd module use the sd-switch application to perform
the unit switch during a generation activation.
Since the closure of sd-switch is relatively lightweight we
unconditionally pull it in as a dependency. We simultaneously remove
the `systemd.user.startServices` option and perform the switch action
automatically.
PR #1388
- Pass arguments verbatim to the `systemctl` subprocess, obviating the
need for shell escaping.
- Use open3 for capturing subprocess output.
- Fix printing of commands during dry run.
- Simplify `X-RestartIfChanged` regular expression.
1. Use \s to match whitespace, \b to match a word boundary.
2. Rename variable to conform to Ruby's underscore naming
conventions.
- Remove no-op set operation. Specifically, 'no_restart' and 'to_stop'
are disjunct since
1. After reloading the daemon with the new generation, units in
'to_stop' (i.e. units from the old gen that are missing in the
new gen) are not registered anymore in the systemd daemon.
2. Hence, 'systemctl cat' returns no output for these units.
3. Because this output is needed to detect 'no_restart' units,
'no_restart' includes no units from 'to_stop'.
So 'to_stop -= to_restart' is a no-op.
- Only notify about units that would otherwise be restarted. That is,
exclude units that are started but not restarted.
- Previously, all inactive units, like short-running services, were
handled as failed units.
Now systemd activation doesn't fail for oneshot services like
'setxkbmap' while 'servicesStartTimeoutMs' is set.
- Don't start unchanged oneshot services.
PR #1110
Having this in the unit file will prevent the file from being
restarted if a change is detected. This is useful if data loss may
occur if the unit is suddenly restarted. For example, restarting the
Emacs service may result in the loss of unsaved open buffers.