summary refs log tree commit diff
path: root/pkgs/development/libraries/dbus
diff options
context:
space:
mode:
authorNikolay Amiantov <ab@fmap.me>2017-02-16 14:55:38 +0300
committerNikolay Amiantov <ab@fmap.me>2017-02-16 15:41:23 +0300
commit3e23ec44503df219b8a705357eafd1f3960f34d9 (patch)
tree4882dc0d805f03004bb21ac155418c9cc78043a1 /pkgs/development/libraries/dbus
parent300c9a6c3d73cb486fca6385271acc2cd341ed51 (diff)
downloadnixpkgs-3e23ec44503df219b8a705357eafd1f3960f34d9.tar
nixpkgs-3e23ec44503df219b8a705357eafd1f3960f34d9.tar.gz
nixpkgs-3e23ec44503df219b8a705357eafd1f3960f34d9.tar.bz2
nixpkgs-3e23ec44503df219b8a705357eafd1f3960f34d9.tar.lz
nixpkgs-3e23ec44503df219b8a705357eafd1f3960f34d9.tar.xz
nixpkgs-3e23ec44503df219b8a705357eafd1f3960f34d9.tar.zst
nixpkgs-3e23ec44503df219b8a705357eafd1f3960f34d9.zip
makeDBusConf: init
Use XSLT transform to modify stock dbus configuration file. This is needed
because some dbus components doesn't support <include> so we need to put our
core configuration in the main file.
Diffstat (limited to 'pkgs/development/libraries/dbus')
-rw-r--r--pkgs/development/libraries/dbus/make-dbus-conf.nix27
-rw-r--r--pkgs/development/libraries/dbus/make-session-conf.xsl30
-rw-r--r--pkgs/development/libraries/dbus/make-system-conf.xsl34
3 files changed, 91 insertions, 0 deletions
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 <include>
+ * 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 @@
+<?xml version="1.0"?>
+
+<!--
+  This script copies the original system.conf from the dbus
+  distribution, but sets paths from $serviceDirectories parameter
+  and suid helper from $suidHelper parameter.
+-->
+
+<xsl:stylesheet version="1.0"
+                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:str="http://exslt.org/strings"
+                extension-element-prefixes="str"
+                >
+
+  <xsl:output method='xml' encoding="UTF-8" doctype-system="busconfig.dtd" />
+
+  <xsl:param name="serviceDirectories" />
+
+  <xsl:template match="/busconfig">
+    <busconfig>
+      <xsl:copy-of select="child::node()[name() != 'include' and name() != 'standard_session_servicedirs' and name() != 'servicedir' and name() != 'includedir']" />
+
+      <xsl:for-each select="str:tokenize($serviceDirectories)">
+        <servicedir><xsl:value-of select="." />/share/dbus-1/services</servicedir>
+        <includedir><xsl:value-of select="." />/etc/dbus-1/session.d</includedir>
+      </xsl:for-each>
+    </busconfig>
+  </xsl:template>
+
+</xsl:stylesheet>
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 @@
+<?xml version="1.0"?>
+
+<!--
+  This script copies the original system.conf from the dbus
+  distribution, but sets paths from $serviceDirectories parameter
+  and suid helper from $suidHelper parameter.
+-->
+
+<xsl:stylesheet version="1.0"
+                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:str="http://exslt.org/strings"
+                extension-element-prefixes="str"
+                >
+
+  <xsl:output method='xml' encoding="UTF-8" doctype-system="busconfig.dtd" />
+
+  <xsl:param name="serviceDirectories" />
+  <xsl:param name="suidHelper" />
+
+  <xsl:template match="/busconfig">
+    <busconfig>
+      <xsl:copy-of select="child::node()[name() != 'include' and name() != 'standard_system_servicedirs' and name() != 'servicehelper' and name() != 'servicedir' and name() != 'includedir']" />
+
+      <!-- set suid helper -->
+      <servicehelper><xsl:value-of select="$suidHelper" /></servicehelper>
+
+      <xsl:for-each select="str:tokenize($serviceDirectories)">
+        <servicedir><xsl:value-of select="." />/share/dbus-1/system-services</servicedir>
+        <includedir><xsl:value-of select="." />/etc/dbus-1/system.d</includedir>
+      </xsl:for-each>
+    </busconfig>
+  </xsl:template>
+
+</xsl:stylesheet>