summary refs log tree commit diff
path: root/nixos/modules/services/system/dbus.nix
diff options
context:
space:
mode:
authorPeter Hoeg <peter@speartail.com>2016-04-02 23:11:57 +0800
committerPeter Hoeg <peter@speartail.com>2016-04-02 23:11:57 +0800
commit83cb6ec399e067b0d111abc39381204d1796758f (patch)
tree4e1b22995689692d0a4351bd64abe1f4dc751dbf /nixos/modules/services/system/dbus.nix
parent32b7b0009f168cb7e020d297c2f336ef352e9ec1 (diff)
downloadnixpkgs-83cb6ec399e067b0d111abc39381204d1796758f.tar
nixpkgs-83cb6ec399e067b0d111abc39381204d1796758f.tar.gz
nixpkgs-83cb6ec399e067b0d111abc39381204d1796758f.tar.bz2
nixpkgs-83cb6ec399e067b0d111abc39381204d1796758f.tar.lz
nixpkgs-83cb6ec399e067b0d111abc39381204d1796758f.tar.xz
nixpkgs-83cb6ec399e067b0d111abc39381204d1796758f.tar.zst
nixpkgs-83cb6ec399e067b0d111abc39381204d1796758f.zip
dbus nixos module: add units for systemd user session
This patch makes dbus launch with any user session instead of
leaving it up to the desktop environment launch script to run it.

It has been tested with KDE, which simply uses the running daemon
instead of launching its own.

This is upstream's recommended way to run dbus.
Diffstat (limited to 'nixos/modules/services/system/dbus.nix')
-rw-r--r--nixos/modules/services/system/dbus.nix24
1 files changed, 24 insertions, 0 deletions
diff --git a/nixos/modules/services/system/dbus.nix b/nixos/modules/services/system/dbus.nix
index 77427ce9606..ba34eb25169 100644
--- a/nixos/modules/services/system/dbus.nix
+++ b/nixos/modules/services/system/dbus.nix
@@ -139,6 +139,30 @@ in
 
     systemd.services.dbus.restartTriggers = [ configDir ];
 
+    systemd.user = {
+      services.dbus = {
+        description = "D-Bus User Message Bus";
+        requires = [ "dbus.socket" ];
+        # NixOS doesn't support "Also" so we pull it in manually
+        # As the .service is supposed to come up at the same time as
+        # the .socket, we use basic.target instead of default.target
+        wantedBy = [ "basic.target" ];
+        serviceConfig = {
+          ExecStart = "${pkgs.dbus_daemon}/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation";
+          ExecReload = "${pkgs.dbus_daemon}/bin/dbus-send --print-reply --session --type=method_call --dest=org.freedesktop.DBus / org.freedesktop.DBus.ReloadConfig";
+        };
+      };
+
+      sockets.dbus = {
+        description = "D-Bus User Message Bus Socket";
+        socketConfig = {
+          ListenStream = "%t/bus";
+          ExecStartPost = "-${config.systemd.package}/bin/systemctl --user set-environment DBUS_SESSION_BUS_ADDRESS=unix:path=%t/bus";
+        };
+        wantedBy = [ "sockets.target" ];
+      };
+    };
+
     environment.pathsToLink = [ "/etc/dbus-1" "/share/dbus-1" ];
 
   };