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
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 __darwinAllowLocalNetworking = true;
71
72 configureFlags = [
73 "--enable-user-session"
74 "--enable-xml-docs"
75 "--libexecdir=${placeholder "out"}/libexec"
76 "--datadir=/etc"
77 "--localstatedir=/var"
78 "--runstatedir=/run"
79 "--sysconfdir=/etc"
80 "--with-session-socket-dir=/tmp"
81 "--with-system-pid-file=/run/dbus/pid"
82 "--with-system-socket=/run/dbus/system_bus_socket"
83 "--with-systemdsystemunitdir=${placeholder "out"}/etc/systemd/system"
84 "--with-systemduserunitdir=${placeholder "out"}/etc/systemd/user"
85 ] ++ lib.optional (!x11Support) "--without-x"
86 ++ lib.optionals stdenv.isLinux [ "--enable-apparmor" "--enable-libaudit" ]
87 ++ lib.optionals enableSystemd [ "SYSTEMCTL=${systemdMinimal}/bin/systemctl" ];
88
89 NIX_CFLAGS_LINK = lib.optionalString (!stdenv.isDarwin) "-Wl,--as-needed";
90
91 enableParallelBuilding = true;
92
93 doCheck = true;
94
95 makeFlags = [
96 # Fix paths in XML catalog broken by mismatching build/install datadir.
97 "dtddir=${placeholder "out"}/share/xml/dbus-1"
98 ];
99
100 installFlags = [
101 "sysconfdir=${placeholder "out"}/etc"
102 "datadir=${placeholder "out"}/share"
103 ];
104
105 # it's executed from $lib by absolute path
106 postFixup = ''
107 moveToOutput bin/dbus-launch "$lib"
108 ln -s "$lib/bin/dbus-launch" "$out/bin/"
109 '';
110
111 passthru = {
112 dbus-launch = "${dbus.lib}/bin/dbus-launch";
113 };
114
115 meta = with lib; {
116 description = "Simple interprocess messaging system";
117 homepage = "https://www.freedesktop.org/wiki/Software/dbus/";
118 changelog = "https://gitlab.freedesktop.org/dbus/dbus/-/blob/dbus-${version}/NEWS";
119 license = licenses.gpl2Plus; # most is also under AFL-2.1
120 maintainers = teams.freedesktop.members ++ (with maintainers; [ ]);
121 platforms = platforms.unix;
122 };
123}