1{ stdenv
2, lib
3, fetchurl
4, pkg-config
5, expat
6, enableSystemd ? lib.meta.availableOn stdenv.hostPlatform systemdMinimal
7, systemdMinimal
8, audit
9, libapparmor
10, dbus
11, docbook_xml_dtd_44
12, docbook-xsl-nons
13, xmlto
14, autoreconfHook
15, autoconf-archive
16, x11Support ? (stdenv.isLinux || stdenv.isDarwin)
17, xorg
18}:
19
20stdenv.mkDerivation rec {
21 pname = "dbus";
22 version = "1.14.6";
23
24 src = fetchurl {
25 url = "https://dbus.freedesktop.org/releases/dbus/dbus-${version}.tar.xz";
26 sha256 = "sha256-/SvfG7idw2WkZTG/9jFTbyKw0cbVzixcXlm1UmWz1ms=";
27 };
28
29 patches = lib.optional stdenv.isSunOS ./implement-getgrouplist.patch;
30
31 postPatch = ''
32 substituteInPlace bus/Makefile.am \
33 --replace 'install-data-hook:' 'disabled:' \
34 --replace '$(mkinstalldirs) $(DESTDIR)$(localstatedir)/run/dbus' ':'
35 substituteInPlace tools/Makefile.am \
36 --replace 'install-data-local:' 'disabled:' \
37 --replace 'installcheck-local:' 'disabled:'
38 '' + /* cleanup of runtime references */ ''
39 substituteInPlace ./dbus/dbus-sysdeps-unix.c \
40 --replace 'DBUS_BINDIR "/dbus-launch"' "\"$lib/bin/dbus-launch\""
41 substituteInPlace ./tools/dbus-launch.c \
42 --replace 'DBUS_DAEMONDIR"/dbus-daemon"' '"/run/current-system/sw/bin/dbus-daemon"'
43 '';
44
45 outputs = [ "out" "dev" "lib" "doc" "man" ];
46
47 strictDeps = true;
48 nativeBuildInputs = [
49 autoreconfHook
50 autoconf-archive
51 pkg-config
52 docbook_xml_dtd_44
53 docbook-xsl-nons
54 xmlto
55 ];
56
57 propagatedBuildInputs = [
58 expat
59 ];
60
61 buildInputs =
62 lib.optionals x11Support (with xorg; [
63 libX11
64 libICE
65 libSM
66 ]) ++ lib.optional enableSystemd systemdMinimal
67 ++ lib.optionals stdenv.isLinux [ audit libapparmor ];
68 # ToDo: optional selinux?
69
70 configureFlags = [
71 "--enable-user-session"
72 "--enable-xml-docs"
73 "--libexecdir=${placeholder "out"}/libexec"
74 "--datadir=/etc"
75 "--localstatedir=/var"
76 "--runstatedir=/run"
77 "--sysconfdir=/etc"
78 "--with-session-socket-dir=/tmp"
79 "--with-system-pid-file=/run/dbus/pid"
80 "--with-system-socket=/run/dbus/system_bus_socket"
81 "--with-systemdsystemunitdir=${placeholder "out"}/etc/systemd/system"
82 "--with-systemduserunitdir=${placeholder "out"}/etc/systemd/user"
83 ] ++ lib.optional (!x11Support) "--without-x"
84 ++ lib.optionals stdenv.isLinux [ "--enable-apparmor" "--enable-libaudit" ]
85 ++ lib.optionals enableSystemd [ "SYSTEMCTL=${systemdMinimal}/bin/systemctl" ];
86
87 NIX_CFLAGS_LINK = lib.optionalString (!stdenv.isDarwin) "-Wl,--as-needed";
88
89 enableParallelBuilding = true;
90
91 doCheck = true;
92
93 makeFlags = [
94 # Fix paths in XML catalog broken by mismatching build/install datadir.
95 "dtddir=${placeholder "out"}/share/xml/dbus-1"
96 ];
97
98 installFlags = [
99 "sysconfdir=${placeholder "out"}/etc"
100 "datadir=${placeholder "out"}/share"
101 ];
102
103 # it's executed from $lib by absolute path
104 postFixup = ''
105 moveToOutput bin/dbus-launch "$lib"
106 ln -s "$lib/bin/dbus-launch" "$out/bin/"
107 '';
108
109 passthru = {
110 dbus-launch = "${dbus.lib}/bin/dbus-launch";
111 };
112
113 meta = with lib; {
114 description = "Simple interprocess messaging system";
115 homepage = "http://www.freedesktop.org/wiki/Software/dbus/";
116 license = licenses.gpl2Plus; # most is also under AFL-2.1
117 maintainers = teams.freedesktop.members ++ (with maintainers; [ ]);
118 platforms = platforms.unix;
119 };
120}