From a4f9ab000564187663c79e2dd68c74bae98012e7 Mon Sep 17 00:00:00 2001 From: winston Date: Mon, 30 Jun 2025 01:09:58 +0200 Subject: [PATCH] sway: add `wayland.windowManager.sway.systemd.dbusImplementation` (#7271) Allows the user to choose the dbus implementation for the environment import. See https://github.com/swaywm/sway/wiki#systemd-and-dbus-activation-environments --- .../services/window-managers/i3-sway/sway.nix | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/modules/services/window-managers/i3-sway/sway.nix b/modules/services/window-managers/i3-sway/sway.nix index 66d25b01..1d016da6 100644 --- a/modules/services/window-managers/i3-sway/sway.nix +++ b/modules/services/window-managers/i3-sway/sway.nix @@ -393,7 +393,12 @@ let variables = concatStringsSep " " cfg.systemd.variables; extraCommands = concatStringsSep " && " cfg.systemd.extraCommands; - systemdActivation = ''exec "${pkgs.dbus}/bin/dbus-update-activation-environment --systemd ${variables}; ${extraCommands}"''; + systemdActivation = + { + broker = ''exec "systemctl --user import-environment ${variables}; ${extraCommands}"''; + dbus = ''exec "${pkgs.dbus}/bin/dbus-update-activation-environment --systemd ${variables}; ${extraCommands}"''; + } + .${cfg.systemd.dbusImplementation}; configFile = pkgs.writeTextFile { name = "sway.conf"; @@ -556,6 +561,23 @@ in ''; }; + dbusImplementation = mkOption { + type = types.enum [ + "dbus" + "broker" + ]; + default = "dbus"; + example = "broker"; + description = '' + The D-Bus implementation used on the system. + This affects which tool is used to import environment variables when starting the Sway session. + On NixOS, this should match the value of the option [`services.dbus.implementation` (NixOS)](https://nixos.org/manual/nixos/stable/options#opt-services.dbus.implementation). + When set to `dbus`, `dbus-update-activation-environment --systemd ` is run. + Otherwise, when set to `broker`, `systemctl --user import-environment ` is run. + See for more documentation. + ''; + }; + extraCommands = mkOption { type = types.listOf types.str; default = [