nixos/dbus: fix switching from dbus-broker to dbus

This commit is contained in:
Sandro Jäckel 2024-05-04 18:12:54 +02:00
parent 95e4dd69a2
commit 21ab17debe
No known key found for this signature in database
GPG Key ID: 3AF5A43A3EECC2E5
2 changed files with 15 additions and 0 deletions

View File

@ -147,6 +147,10 @@ in
};
systemd.services.dbus = {
aliases = [
# hack aiding to prevent dbus from restarting when switching from dbus-broker back to dbus
"dbus-broker.service"
];
# Don't restart dbus-daemon. Bad things tend to happen if we do.
reloadIfChanged = true;
restartTriggers = [
@ -158,6 +162,10 @@ in
};
systemd.user.services.dbus = {
aliases = [
# hack aiding to prevent dbus from restarting when switching from dbus-broker back to dbus
"dbus-broker.service"
];
# Don't restart dbus-daemon. Bad things tend to happen if we do.
reloadIfChanged = true;
restartTriggers = [
@ -184,6 +192,8 @@ in
# https://github.com/NixOS/nixpkgs/issues/108643
systemd.services.dbus-broker = {
aliases = [
# allow other services to just depend on dbus,
# but also a hack aiding to prevent dbus from restarting when switching from dbus-broker back to dbus
"dbus.service"
];
unitConfig = {
@ -203,6 +213,8 @@ in
systemd.user.services.dbus-broker = {
aliases = [
# allow other services to just depend on dbus,
# but also a hack aiding to prevent dbus from restarting when switching from dbus-broker back to dbus
"dbus.service"
];
# Don't restart dbus. Bad things tend to happen if we do.

View File

@ -472,6 +472,9 @@ sub handle_modified_unit { ## no critic(Subroutines::ProhibitManyArgs, Subroutin
$units_to_reload->{$unit} = 1;
record_unit($reload_list_file, $unit);
}
elsif ($unit eq "dbus.service" || $unit eq "dbus-broker.service") {
# dbus service should only ever be reloaded, not started/stoped/restarted as that would break the system.
}
elsif (!parse_systemd_bool(\%new_unit_info, "Service", "X-RestartIfChanged", 1) || parse_systemd_bool(\%new_unit_info, "Unit", "RefuseManualStop", 0) || parse_systemd_bool(\%new_unit_info, "Unit", "X-OnlyManualStart", 0)) {
$units_to_skip->{$unit} = 1;
} else {