D-Bus in Ironforge

Ironforge is a single-user system. Root's desktop programs share one session bus, supervised by dinit. The system bus remains separate because system services and desktop programs use different D-Bus interfaces and policies.

System bus (dbus)
Socket: /run/dbus/system_bus_socket
Used by system services, including Bluetooth.

Root session bus (dbus-session)
Socket: /run/user/0/bus
Shared by Anvil, desktop applications, audio services and portals.

Startup and lifetime

early-setup creates /run/dbus and /run/user/0. The latter is owned by root with mode 0700. The session service uses:

type = process
command = /usr/bin/dbus-daemon --session --nofork --address=unix:path=/run/user/0/bus --print-address=3
depends-on = early-setup
env-file = /etc/dinit.d/env/desktop
ready-notification = pipefd:3
restart = true
restart-delay = 5
logfile = /var/log/dbus-session.log

Neo also has depends-on = luks-root, so activation can access the mounted root home directory. boot includes waits-for = dbus-session independently of the desktop. Anvil and PipeWire require dbus-session; PipeWire Pulse and WirePlumber depend on PipeWire. Dinit waits for the daemon to print its listening address before starting these dependents.

The desktop and audio service environments, and root's Bash login and Fish configuration, export:

XDG_RUNTIME_DIR=/run/user/0
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/0/bus

After changing a dinit environment file, reload each affected service definition before restarting its processes; restarting alone can retain the loaded environment.

Anvil updates the bus activation environment with its actual Wayland display and desktop settings, allowing D-Bus to launch portals with the right environment. Flatpak applications reach the host buses through their permission-filtered proxies. Accessibility services can also have a separate bus.

Restarting Anvil preserves the session bus and its identity, although graphical clients may exit when their display disappears. Restarting the bus itself disconnects clients and may require restarting them. Older installations wrapped Anvil in dbus-run-session; the managed desktop now connects directly to the dinit-owned bus.

Checking the setup

dinitctl status dbus
dinitctl status dbus-session
dbus-send --bus=unix:path=/run/user/0/bus --print-reply \
  --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetId
tail -n 30 /var/log/dbus-session.log

The session bus PID and GetId result should stay unchanged across an Anvil restart. Explicitly selecting the address also works from administrative SSH commands that do not read login-shell configuration.