diff --git a/nixos/modules/services/system/dbus-session-local.conf.in b/nixos/modules/services/system/dbus-session-local.conf.in
deleted file mode 100644
index 5fd6f80a353..00000000000
--- a/nixos/modules/services/system/dbus-session-local.conf.in
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- @extra@
-
diff --git a/nixos/modules/services/system/dbus-system-local.conf.in b/nixos/modules/services/system/dbus-system-local.conf.in
deleted file mode 100644
index edbb476f585..00000000000
--- a/nixos/modules/services/system/dbus-system-local.conf.in
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- @servicehelper@
- @extra@
-
diff --git a/nixos/modules/services/system/dbus.nix b/nixos/modules/services/system/dbus.nix
index 33bc890a78c..643bec18814 100644
--- a/nixos/modules/services/system/dbus.nix
+++ b/nixos/modules/services/system/dbus.nix
@@ -10,32 +10,10 @@ let
homeDir = "/run/dbus";
- systemExtraxml = concatStrings (flip concatMap cfg.packages (d: [
- "${d}/share/dbus-1/system-services"
- "${d}/etc/dbus-1/system.d"
- ]));
-
- sessionExtraxml = concatStrings (flip concatMap cfg.packages (d: [
- "${d}/share/dbus-1/services"
- "${d}/etc/dbus-1/session.d"
- ]));
-
- configDir = pkgs.runCommand "dbus-conf"
- { preferLocalBuild = true;
- allowSubstitutes = false;
- }
- ''
- mkdir -p $out
-
- sed '${./dbus-system-local.conf.in}' \
- -e 's,@servicehelper@,${config.security.wrapperDir}/dbus-daemon-launch-helper,g' \
- -e 's,@extra@,${systemExtraxml},' \
- > "$out/system-local.conf"
-
- sed '${./dbus-session-local.conf.in}' \
- -e 's,@extra@,${sessionExtraxml},' \
- > "$out/session-local.conf"
- '';
+ configDir = pkgs.makeDBusConf {
+ suidHelper = "${config.security.wrapperDir}/dbus-daemon-launch-helper";
+ serviceDirectories = cfg.packages;
+ };
in
diff --git a/pkgs/development/libraries/dbus/default.nix b/pkgs/development/libraries/dbus/default.nix
index 7743c1e3f80..49b71ff9974 100644
--- a/pkgs/development/libraries/dbus/default.nix
+++ b/pkgs/development/libraries/dbus/default.nix
@@ -50,7 +50,8 @@ self = stdenv.mkDerivation {
"--with-systemdsystemunitdir=$(out)/etc/systemd/system"
"--with-systemduserunitdir=$(out)/etc/systemd/user"
"--enable-user-session"
- "--libexecdir=$(out)/libexec" # we don't need dbus-daemon-launch-helper
+ "--datadir=/etc"
+ "--libexecdir=$(out)/libexec"
] ++ lib.optional (!x11Support) "--without-x";
# Enable X11 autolaunch support in libdbus. This doesn't actually depend on X11
@@ -63,7 +64,12 @@ self = stdenv.mkDerivation {
doCheck = true;
- installFlags = [ "sysconfdir=$(out)/etc" ];
+ installFlags = [ "sysconfdir=$(out)/etc" "datadir=$(out)/share" ];
+
+ postInstall = ''
+ mkdir -p $doc/share/xml/dbus
+ cp doc/*.dtd $doc/share/xml/dbus
+ '';
# it's executed from $lib by absolute path
postFixup = ''
diff --git a/pkgs/development/libraries/dbus/make-dbus-conf.nix b/pkgs/development/libraries/dbus/make-dbus-conf.nix
new file mode 100644
index 00000000000..7e35a9162c8
--- /dev/null
+++ b/pkgs/development/libraries/dbus/make-dbus-conf.nix
@@ -0,0 +1,27 @@
+{ runCommand, libxslt, dbus, serviceDirectories ? [], suidHelper ? "/var/setuid-wrappers/dbus-daemon-launch-helper" }:
+
+/* DBus has two configuration parsers -- normal and "trivial", which is used
+ * for suid helper. Unfortunately the latter doesn't support
+ * directive. That means that we can't just place our configuration to
+ * *-local.conf -- it needs to be in the main configuration file.
+ */
+runCommand "dbus-1"
+ {
+ buildInputs = [ libxslt ];
+ inherit serviceDirectories suidHelper;
+ }
+ ''
+ mkdir -p $out
+
+ xsltproc \
+ --stringparam serviceDirectories "$serviceDirectories" \
+ --stringparam suidHelper "$suidHelper" \
+ --path ${dbus.doc}/share/xml/dbus \
+ ${./make-system-conf.xsl} ${dbus}/share/dbus-1/system.conf \
+ > $out/system.conf
+ xsltproc \
+ --stringparam serviceDirectories "$serviceDirectories" \
+ --path ${dbus.doc}/share/xml/dbus \
+ ${./make-session-conf.xsl} ${dbus}/share/dbus-1/session.conf \
+ > $out/session.conf
+ ''
diff --git a/pkgs/development/libraries/dbus/make-session-conf.xsl b/pkgs/development/libraries/dbus/make-session-conf.xsl
new file mode 100644
index 00000000000..bc73369af94
--- /dev/null
+++ b/pkgs/development/libraries/dbus/make-session-conf.xsl
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /share/dbus-1/services
+ /etc/dbus-1/session.d
+
+
+
+
+
diff --git a/pkgs/development/libraries/dbus/make-system-conf.xsl b/pkgs/development/libraries/dbus/make-system-conf.xsl
new file mode 100644
index 00000000000..3d8b823437d
--- /dev/null
+++ b/pkgs/development/libraries/dbus/make-system-conf.xsl
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /share/dbus-1/system-services
+ /etc/dbus-1/system.d
+
+
+
+
+
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 2c05a1ea492..78d6cd0e9bf 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -7089,6 +7089,11 @@ with pkgs;
dbus_libs = dbus;
dbus_daemon = dbus.daemon;
+ makeDBusConf = { suidHelper, serviceDirectories }:
+ callPackage ../development/libraries/dbus/make-dbus-conf.nix {
+ inherit suidHelper serviceDirectories;
+ };
+
dee = callPackage ../development/libraries/dee { };
dhex = callPackage ../applications/editors/dhex { };