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.10";
23
24 src = fetchurl {
25 url = "https://dbus.freedesktop.org/releases/dbus/dbus-${version}.tar.xz";
26 sha256 = "sha256-uh8h0r2dM52i1KqHgMCd8y/qh5mLc9ok9Jq53x42pQ8=";
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 separateDebugInfo = true;
47
48 strictDeps = true;
49 nativeBuildInputs = [
50 autoreconfHook
51 autoconf-archive
52 pkg-config
53 docbook_xml_dtd_44
54 docbook-xsl-nons
55 xmlto
56 ];
57
58 propagatedBuildInputs = [
59 expat
60 ];
61
62 buildInputs =
63 lib.optionals x11Support (with xorg; [
64 libX11
65 libICE
66 libSM
67 ]) ++ lib.optional enableSystemd systemdMinimal
68 ++ lib.optionals stdenv.isLinux [ audit libapparmor ];
69 # ToDo: optional selinux?
70
71 __darwinAllowLocalNetworking = true;
72
73 configureFlags = [
74 "--enable-user-session"
75 "--enable-xml-docs"
76 "--libexecdir=${placeholder "out"}/libexec"
77 "--datadir=/etc"
78 "--localstatedir=/var"
79 "--runstatedir=/run"
80 "--sysconfdir=/etc"
81 "--with-session-socket-dir=/tmp"
82 "--with-system-pid-file=/run/dbus/pid"
83 "--with-system-socket=/run/dbus/system_bus_socket"
84 "--with-systemdsystemunitdir=${placeholder "out"}/etc/systemd/system"
85 "--with-systemduserunitdir=${placeholder "out"}/etc/systemd/user"
86 ] ++ lib.optional (!x11Support) "--without-x"
87 ++ lib.optionals stdenv.isLinux [ "--enable-apparmor" "--enable-libaudit" ]
88 ++ lib.optionals enableSystemd [ "SYSTEMCTL=${systemdMinimal}/bin/systemctl" ];
89
90 NIX_CFLAGS_LINK = lib.optionalString (!stdenv.isDarwin) "-Wl,--as-needed";
91
92 enableParallelBuilding = true;
93
94 doCheck = true;
95
96 makeFlags = [
97 # Fix paths in XML catalog broken by mismatching build/install datadir.
98 "dtddir=${placeholder "out"}/share/xml/dbus-1"
99 ];
100
101 installFlags = [
102 "sysconfdir=${placeholder "out"}/etc"
103 "datadir=${placeholder "out"}/share"
104 ];
105
106 # it's executed from $lib by absolute path
107 postFixup = ''
108 moveToOutput bin/dbus-launch "$lib"
109 ln -s "$lib/bin/dbus-launch" "$out/bin/"
110 '';
111
112 passthru = {
113 dbus-launch = "${dbus.lib}/bin/dbus-launch";
114 };
115
116 meta = with lib; {
117 description = "Simple interprocess messaging system";
118 homepage = "https://www.freedesktop.org/wiki/Software/dbus/";
119 changelog = "https://gitlab.freedesktop.org/dbus/dbus/-/blob/dbus-${version}/NEWS";
120 license = licenses.gpl2Plus; # most is also under AFL-2.1
121 maintainers = teams.freedesktop.members ++ (with maintainers; [ ]);
122 platforms = platforms.unix;
123 };
124}