Dbus-update-activation-environment & sway?

I’m using sway, and I noticed that the dbus-update-activation-environment
executable provided by the dbus package is not in the path; so when
.config/sway/config includes /etc/sway/config.d/nixos, which has this contents:

# Import the most important environment variables into the D-Bus and systemd
# user environments (e.g. required for screen sharing and Pinentry prompts):
exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP

it has no effect. Likewise, the dbus-sway-environment workaround in the example configuration shown in the NixOS Sway wiki page does not work, since the script that it creates tries to directly execute dbus-update-activation-environment, which is not in the path.

The dbus-update-activation-environment executable seems to be located under the dbus package in the nix store at a path similar to


but there is no store entry for the dbus-update-activation-environment executable itself, and
no symlink for dbus-update-activation-environment under /run/current-system/sw/bin/.

Possibly because of this, the xdg-desktop-portal-wlr.service does not start as a user service, since it doesn’t find WAYLAND_DISPLAY in the appropriate environment. (Note, working from a shell inside a sway session, all of the environment variables DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP are set, but that apparently does not apply to the environment used to start xdg-desktop-portal-wlr.service).

Although I could probably find a hack workaround for the above, I’m quite new at NixOS and I’m not sure what the best way to fix it would be.

Suggestions are welcome!

Interesting, it does seem that the use of dbus-update-activation-environment is not a full store reference in the NixOS module. I might recommend going ahead and filing this as an Issue on nixos/nixpkgs.

From what I can tell, this issue does not affect the home-manager module, as it properly references the dbus store path. I’m a bit surprised this hasn’t been noticed. I wonder if most Sway users are using Home-Manager? As you observe, this missing in the NixOS module means that non-HM-users are likely having problems with user services that expect certain env vars to be set in the user-systemd environment.

EDIT: Alternatively, it seems like you understand the issue. If you want to just fix this in nixpkgs, I’d be happy to review/merge it for you.

Thanks for confirmation! I’ll file an issue, and if I’m feeling up to it, may try to provide a patch.

It turns out that adding pkgs.dbus to environment.systemPackages in configuration.nix
is enough to get the /run/current-system/sw/bin/dbus-update-activation-environment symlink
in PATH, which allows the calls to execute dbus-update-activation-environment (not specifiying a path) to succeed. I’ve updated the Sway wiki page accordingly.

1 Like