Would it be feasible to make dbus-broker the default dbus implementation? [Implemented]

I saw that Archlinux is using it as the default implementation now and was curious about what is blocking this? Fedora’s been using it for a while and it seems to be pretty much set and forget it. I’ve been using on my system for about 3 months and haven’t noticed anything.

Edit: implemented in dbus: Switch default implementation to broker by LDprg · Pull Request #299812 · NixOS/nixpkgs · GitHub.

3 Likes

i’ve been running it on quite a few NixOS systems running inside lxc for a while with no complaints

1 Like

Yeah we should write an RFC, I guess best if someone experienced takes over that responsibility.

I’ve been using dbus-broker since ArchLinux switched to default, on multiple desktops, and I’ve not observed any unwanted behaviors.

1 Like

Not sure that this needs an RFC. I think a PR that switches the default and adds an entry to the release notes is sufficient, together with a post on discourse to announce the imminent change (so people can opt out beforehand). We can then leave a bit of time for feedback in case anyone has a really good reason not to go ahead with it.

7 Likes

IMO, probably yes (and some more chars)

2 Likes

Nothing against the change, but for those like me that didn’t know about it, why the change?

Things I would like in an alt DBus broker implementation:

  • Alt ubiquitous serialization (ie. JSON).
    • DBus serialization format is good but too specific. Maybe BSON, MsgPack, Protobuf, faster than JSON, less ubiquitous than JSON, more than DBus.
  • Alt IPC protocol (ie. ???, gRPC?, msgpack-rpc?).
    • Same of the previous point, but there is no ubiquitous IPC.

But none of those are intended to be implemented dbus-broker :sweat_smile:

1 Like

https://www.phoronix.com/news/Arch-Linux-Dbus-Broker wrote:

better performance and reliability along with better systemd integration

in conjunction with

dbus-broker wiki wrote:

[…] makes use of many modern features provided by recent linux kernel releases. […]

Generally the dbus-broker wiki is the best resource I could find to the date, outlining more in depth details.

In the end, this was the outcome of kdbus not making it into the kernel - whilst people still being interested rewriting the original dbus implementation from scratch.

Since the project aims for being a drop-in replacement and I’ve not seen efforts to replace serialization or IPC I would not expect this to happen.

1 Like

I’ve been using on my system for about 3 months and haven’t noticed anything.

Could you share that config? I’d like to try also.

2 Likes
services.dbus.implementation = "broker";

Reference NixOS Search

2 Likes

Another source is Fedora’s Change Proposal.

1 Like

Lists a good point, in NixOS dbus is not split into dbus-daemon and dbus-utils yet.

2 Likes

I tried switching to dbus broker before, but it always breaks my xdg-desktop-portals.

I keep all the other settings the same, change the implementation and reboot and suddenly the portals don’t start anymore and theming in flatpak apps is broken.

1 Like

Would you mind sharing some more information on that? I’ve tried to do some web search regarding xdg-desktop-portal and dbus-broker and couldn’t find something. For me personally xdg-desktop-portal-wlr works as expected, including screen sharing, but also gnome-disks.

1 Like

Yes of course.

I run river as my compositor and have the following commands in my startup config (but everything also seems to work without those on regular dbus):

exec systemctl --user import-environment XDG_SESSION_TYPE XDG_CURRENT_DESKTOP &
exec dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=river &

I simply have dbus enabled (and when i try to switch, also the broker implementation):

services.dbus = {
	enable = true;
	implementation = "broker";
};

And that is my xdg-deskop-portal config:

xdg.portal = {
	enable = true;
	wlr.enable = true;
	extraPortals = [ pkgs.xdg-desktop-portal-gtk ];

	config = {
		common = { 
		default = [ "gtk" ]; 
		"org.freedesktop.impl.portal.Screencast" = [ "wlr" ];
		"org.freedesktop.impl.portal.Screenshot" = [ "wlr" ];
		};

	};
};

On regular dbus, i can see the wlr and gtk portal running in htop and theming (fonts, dark mode) work properly.

With broker, the gtk and wlr portals simply aren’t running at all. And i’m not sure why.

3 Likes

I switched to dbus-broker to see what would happen. I haven’t noticed any issues, however I do see warnings and errors in the systemd journal:

U Sat Mar 30 16:43:52 2024 p3 dbus-broker.service dbus-broker-launch[1801]: Ignoring duplicate name 'org.opensuse.CupsPkHelper.Mechanis
m' in service file '/nix/store/3z9d6iir0ikbgwxm9bzg5cpfd5id6r75-cups-pk-helper-0.2.6/share/dbus-1/system-services/org.opensuse.CupsPkHe
lper.Mechanism.service'
U Sat Mar 30 16:43:52 2024 p3 dbus-broker.service dbus-broker-launch[1801]: Ignoring duplicate name 'org.freedesktop.ModemManager1' in
service file '/nix/store/r8makyq7kwn9mj3b54bagjcfyghjg9kj-modemmanager-1.22.0/share/dbus-1/system-services/org.freedesktop.ModemManager
1.service'
U Sat Mar 30 16:43:52 2024 p3 dbus-broker.service dbus-broker-launch[1801]: Ignoring duplicate name 'org.freedesktop.nm_dispatcher' in
service file '/nix/store/3smcvkky0inrnw2kdsflxh34in0sn2qp-networkmanager-1.46.0/share/dbus-1/system-services/org.freedesktop.nm_dispatc
her.service'
U Sat Mar 30 16:43:52 2024 p3 dbus-broker.service dbus-broker-launch[1801]: Ignoring duplicate name 'org.freedesktop.nm_priv_helper' in
 service file '/nix/store/3smcvkky0inrnw2kdsflxh34in0sn2qp-networkmanager-1.46.0/share/dbus-1/system-services/org.freedesktop.nm_priv_h
elper.service'
U Sat Mar 30 16:43:52 2024 p3 dbus-broker.service dbus-broker-launch[1801]: Ignoring duplicate name 'fi.w1.wpa_supplicant1' in service
file '/nix/store/8fvfgwjygc3lh5vk9k1d6fsvlgxfidrf-wpa_supplicant-2.10/share/dbus-1/system-services/fi.w1.wpa_supplicant1.service'
U Sat Mar 30 16:43:52 2024 p3 dbus-broker.service dbus-broker-launch[1801]: Ignoring duplicate name 'org.freedesktop.UDisks2' in servic
e file '/nix/store/4drhcgvfw5ajwy9gy10w2bz8c7n03mfl-udisks-2.10.1/share/dbus-1/system-services/org.freedesktop.UDisks2.service'
U Sat Mar 30 16:43:52 2024 p3 dbus-broker.service dbus-broker-launch[1801]: Ignoring duplicate name 'org.bluez.mesh' in service file '/
nix/store/3y7sp3w7x3nrj7a98klwsgsv3yrgh7rs-bluez-5.72/share/dbus-1/system-services/org.bluez.mesh.service'
U Sat Mar 30 16:43:52 2024 p3 dbus-broker.service dbus-broker-launch[1801]: Ignoring duplicate name 'org.bluez' in service file '/nix/s
tore/3y7sp3w7x3nrj7a98klwsgsv3yrgh7rs-bluez-5.72/share/dbus-1/system-services/org.bluez.service'
U Sat Mar 30 16:43:52 2024 p3 dbus-broker.service dbus-broker-launch[1801]: Ignoring duplicate name 'org.freedesktop.Accounts' in servi
ce file '/nix/store/zaqxvczv831bl2ngv8g8p7jwxlqxil0i-accountsservice-23.13.9/share/dbus-1/system-services/org.freedesktop.Accounts.serv
ice'
U Sat Mar 30 15:17:50 2024 p3 rtkit-daemon.service rtkit-daemon[38999]: dbus_message_get_unix_user() failed: The connection does not ex
ist
U Sat Mar 30 15:17:50 2024 p3 rtkit-daemon.service rtkit-daemon[38999]: dbus_message_get_unix_user() failed: The connection does not ex
ist
U Sat Mar 30 15:31:10 2024 p3 rtkit-daemon.service rtkit-daemon[38999]: dbus_message_get_unix_user() failed: The connection does not ex
ist

I think I read something that implied dbus-broker just uses the systemd environment, not the dbus activation environment. So, maybe consider checking that those vars are set to what you think they are when calling import-environment.

(I mention since I noticed that you explicitly set the value of XDG_CURRENT_DESKTOP, but only in the dbus-update-activation-environment call.)

I remembered reading somewhere (the Arch Wiki i think) that you still need regular dbus installed when running dbus-broker and i noticed that the “dbus-update-activation-environment” command wasn’t even available after making the switch.

So I added the regular dbus to my system packages (while keeping the broker implementation in my config), i set all the environment variables in my fish config and just run the following command in my river init script now:

dbus-update-activation-environment --systemd --all

And everything works!

1 Like

Hey! Thanks for investigating this further! I would have not spotted this myself. But this leads back to the issue of splitting dbus into dbus-daemon and dbus-utils.. Opened an issue for that.

2 Likes

Update: There is a separate GitHub issue and an ongoing PR that enables dbus broker by default.

2 Likes

:partying_face: dbus-broker as a default got merged, this includes a fix so that also ensures dbus-cli utilities are present, which wasn’t the case when switching to “broker” previously.

If you are on NixOS unstable, make sure to upgrade in the next days with nixos-rebuild boot --upgrade instead of switch, otherwise you risk an unresponsive system. If you need to stay on dbus-daemon by freedesktop, you can do that with services.dbus.implementation = "dbus";.

Please open a GitHub issue if you encounter any problems with dbus-broker.

Warnings such as Ignoring duplicate name are only warnings and should only appear when you are running sudo systemctl reload dbus-broker.

Update 1

Important heads-up, due some regressions of certain services (ncsd for example) dbus-broker was reverted to just dbus. The systemd-team raised interest to be more considered in dbus topics in the future.

Given the current release plans that are publicly known I suspect this means no default dbus-broker in 24.05.

7 Likes