about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/dbus
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/dbus')
-rw-r--r--nixpkgs/pkgs/development/libraries/dbus/default.nix111
-rw-r--r--nixpkgs/pkgs/development/libraries/dbus/implement-getgrouplist.patch108
-rw-r--r--nixpkgs/pkgs/development/libraries/dbus/make-dbus-conf.nix42
-rw-r--r--nixpkgs/pkgs/development/libraries/dbus/make-session-conf.xsl32
-rw-r--r--nixpkgs/pkgs/development/libraries/dbus/make-system-conf.xsl35
5 files changed, 328 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/dbus/default.nix b/nixpkgs/pkgs/development/libraries/dbus/default.nix
new file mode 100644
index 000000000000..a3e3c4ebd89a
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/dbus/default.nix
@@ -0,0 +1,111 @@
+{ stdenv
+, lib
+, fetchurl
+, pkgconfig
+, expat
+, enableSystemd ? stdenv.isLinux && !stdenv.hostPlatform.isMusl
+, systemd
+, libX11 ? null
+, libICE ? null
+, libSM ? null
+, x11Support ? (stdenv.isLinux || stdenv.isDarwin)
+, dbus
+}:
+
+assert
+  x11Support ->
+    libX11 != null && libICE != null && libSM != null;
+
+assert enableSystemd -> systemd != null;
+
+stdenv.mkDerivation rec {
+  pname = "dbus";
+  version = "1.12.16";
+
+  src = fetchurl {
+    url = "https://dbus.freedesktop.org/releases/dbus/dbus-${version}.tar.gz";
+    sha256 = "107ckxaff1cv4q6kmfdi2fb1nlsv03312a7kf6lb4biglhpjv8jl";
+  };
+
+  patches = lib.optional stdenv.isSunOS ./implement-getgrouplist.patch;
+
+  postPatch = ''
+    substituteInPlace tools/Makefile.in \
+      --replace 'install-localstatelibDATA:' 'disabled:' \
+      --replace 'install-data-local:' 'disabled:' \
+      --replace 'installcheck-local:' 'disabled:'
+    substituteInPlace bus/Makefile.in \
+      --replace '$(mkinstalldirs) $(DESTDIR)$(localstatedir)/run/dbus' ':'
+  '' + /* cleanup of runtime references */ ''
+    substituteInPlace ./dbus/dbus-sysdeps-unix.c \
+      --replace 'DBUS_BINDIR "/dbus-launch"' "\"$lib/bin/dbus-launch\""
+    substituteInPlace ./tools/dbus-launch.c \
+      --replace 'DBUS_DAEMONDIR"/dbus-daemon"' '"/run/current-system/sw/bin/dbus-daemon"'
+  '';
+
+  outputs = [ "out" "dev" "lib" "doc" ];
+
+  nativeBuildInputs = [
+    pkgconfig
+  ];
+
+  propagatedBuildInputs = [
+    expat
+  ];
+
+  buildInputs =
+    lib.optionals x11Support [
+      libX11
+      libICE
+      libSM
+    ] ++ lib.optional enableSystemd systemd;
+  # ToDo: optional selinux?
+
+  configureFlags = [
+    "--enable-user-session"
+    "--libexecdir=${placeholder ''out''}/libexec"
+    "--datadir=/etc"
+    "--localstatedir=/var"
+    "--runstatedir=/run"
+    "--sysconfdir=/etc"
+    "--with-session-socket-dir=/tmp"
+    "--with-system-pid-file=/run/dbus/pid"
+    "--with-system-socket=/run/dbus/system_bus_socket"
+    "--with-systemdsystemunitdir=${placeholder ''out''}/etc/systemd/system"
+    "--with-systemduserunitdir=${placeholder ''out''}/etc/systemd/user"
+  ] ++ lib.optional (!x11Support) "--without-x";
+
+  # Enable X11 autolaunch support in libdbus. This doesn't actually depend on X11
+  # (it just execs dbus-launch in dbus.tools), contrary to what the configure script demands.
+  # problems building without x11Support so disabled in that case for now
+  NIX_CFLAGS_COMPILE = lib.optionalString x11Support "-DDBUS_ENABLE_X11_AUTOLAUNCH=1";
+  NIX_CFLAGS_LINK = lib.optionalString (!stdenv.isDarwin) "-Wl,--as-needed";
+
+  enableParallelBuilding = true;
+
+  doCheck = true;
+
+  installFlags = [
+    "sysconfdir=${placeholder ''out''}/etc"
+    "datadir=${placeholder ''out''}/share"
+  ];
+
+  # it's executed from $lib by absolute path
+  postFixup = ''
+    moveToOutput bin/dbus-launch "$lib"
+    ln -s "$lib/bin/dbus-launch" "$out/bin/"
+  '';
+
+  passthru = {
+    dbus-launch = "${dbus.lib}/bin/dbus-launch";
+    daemon = dbus.out;
+  };
+
+  meta = with stdenv.lib; {
+    description = "Simple interprocess messaging system";
+    homepage = "http://www.freedesktop.org/wiki/Software/dbus/";
+    license = licenses.gpl2Plus; # most is also under AFL-2.1
+    maintainers = with maintainers; [ worldofpeace ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/dbus/implement-getgrouplist.patch b/nixpkgs/pkgs/development/libraries/dbus/implement-getgrouplist.patch
new file mode 100644
index 000000000000..e3a4a25cb720
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/dbus/implement-getgrouplist.patch
@@ -0,0 +1,108 @@
+Compatibility patch for Illumos/Solaris and possibly other platforms.
+Implements getgrouplist when not provided by OS.
+Without it, only the user's primary group is used in authentication!
+--- 	1970-01-01 00:00:00.000000000 +0000
++++ dbus-1.6.8/dbus/getgrouplist.c	2013-02-28 13:10:51.081792722 +0000
+@@ -0,0 +1,89 @@
++/*	$OpenBSD: getgrouplist.c,v 1.12 2005/08/08 08:05:34 espie Exp $ */
++/*
++ * Copyright (c) 1991, 1993
++ *	The Regents of the University of California.  All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ *    notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ *    notice, this list of conditions and the following disclaimer in the
++ *    documentation and/or other materials provided with the distribution.
++ * 3. Neither the name of the University nor the names of its contributors
++ *    may be used to endorse or promote products derived from this software
++ *    without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ */
++
++/* OPENBSD ORIGINAL: lib/libc/gen/getgrouplist.c */
++
++/*
++ * get credential
++ */
++#include <sys/types.h>
++#include <string.h>
++#include <unistd.h>
++#include <grp.h>
++
++int
++getgrouplist(const char *uname, gid_t agroup, gid_t *groups, int *grpcnt)
++{
++	struct group *grp;
++	int i, ngroups;
++	int ret, maxgroups;
++	int bail;
++
++	ret = 0;
++	ngroups = 0;
++	maxgroups = *grpcnt;
++
++	/*
++	 * install primary group
++	 */
++	if (ngroups >= maxgroups) {
++		*grpcnt = ngroups;
++		return (-1);
++	}
++	groups[ngroups++] = agroup;
++
++	/*
++	 * Scan the group file to find additional groups.
++	 */
++	setgrent();
++	while ((grp = getgrent())) {
++		if (grp->gr_gid == agroup)
++			continue;
++		for (bail = 0, i = 0; bail == 0 && i < ngroups; i++)
++			if (groups[i] == grp->gr_gid)
++				bail = 1;
++		if (bail)
++			continue;
++		for (i = 0; grp->gr_mem[i]; i++) {
++			if (!strcmp(grp->gr_mem[i], uname)) {
++				if (ngroups >= maxgroups) {
++					ret = -1;
++					goto out;
++				}
++				groups[ngroups++] = grp->gr_gid;
++				break;
++			}
++		}
++	}
++out:
++	endgrent();
++	*grpcnt = ngroups;
++	return (ret);
++}
+--- dbus-1.6.8/dbus/dbus-sysdeps-unix.c.orig	2013-02-28 13:08:52.171215237 +0000
++++ dbus-1.6.8/dbus/dbus-sysdeps-unix.c	2013-02-28 13:13:52.224615146 +0000
+@@ -21,6 +21,10 @@
+  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+  *
+  */
++#ifndef HAVE_GETGROUPLIST
++#include "getgrouplist.c"
++#define HAVE_GETGROUPLIST
++#endif
+ 
+ #include <config.h>
+ 
diff --git a/nixpkgs/pkgs/development/libraries/dbus/make-dbus-conf.nix b/nixpkgs/pkgs/development/libraries/dbus/make-dbus-conf.nix
new file mode 100644
index 000000000000..e714b96b7e9f
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/dbus/make-dbus-conf.nix
@@ -0,0 +1,42 @@
+{ runCommand, writeText, 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"
+  {
+    inherit serviceDirectories suidHelper;
+    preferLocalBuild = true;
+    allowSubstitutes = false;
+    XML_CATALOG_FILES = writeText "dbus-catalog.xml" ''
+      <?xml version="1.0"?>
+      <!DOCTYPE catalog PUBLIC
+        "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN"
+        "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
+
+      <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
+        <rewriteSystem
+          systemIdStartString="http://www.freedesktop.org/standards/dbus/1.0/"
+          rewritePrefix="file://${dbus}/share/xml/dbus-1/"/>
+      </catalog>
+    '';
+    nativeBuildInputs = [ libxslt.bin ];
+  }
+  ''
+    mkdir -p $out
+
+    xsltproc --nonet \
+      --stringparam serviceDirectories "$serviceDirectories" \
+      --stringparam suidHelper "$suidHelper" \
+      ${./make-system-conf.xsl} ${dbus}/share/dbus-1/system.conf \
+      > $out/system.conf
+    xsltproc --nonet \
+      --stringparam serviceDirectories "$serviceDirectories" \
+      ${./make-session-conf.xsl} ${dbus}/share/dbus-1/session.conf \
+      > $out/session.conf
+  ''
diff --git a/nixpkgs/pkgs/development/libraries/dbus/make-session-conf.xsl b/nixpkgs/pkgs/development/libraries/dbus/make-session-conf.xsl
new file mode 100644
index 000000000000..6a19ee14a22c
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/dbus/make-session-conf.xsl
@@ -0,0 +1,32 @@
+<?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>
+      <!-- We leave <standard_session_servicedirs/> because it includes XDG dirs and therefore user Nix profile. -->
+      <xsl:copy-of select="child::node()[name() != 'include' 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>
+        <includedir><xsl:value-of select="." />/share/dbus-1/session.d</includedir>
+      </xsl:for-each>
+    </busconfig>
+  </xsl:template>
+
+</xsl:stylesheet>
diff --git a/nixpkgs/pkgs/development/libraries/dbus/make-system-conf.xsl b/nixpkgs/pkgs/development/libraries/dbus/make-system-conf.xsl
new file mode 100644
index 000000000000..dd644b4bce7c
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/dbus/make-system-conf.xsl
@@ -0,0 +1,35 @@
+<?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>
+        <includedir><xsl:value-of select="." />/share/dbus-1/system.d</includedir>
+      </xsl:for-each>
+    </busconfig>
+  </xsl:template>
+
+</xsl:stylesheet>