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