nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ stdenv
2, lib
3, fetchpatch
4, fetchurl
5, pkg-config
6, expat
7, enableSystemd ? stdenv.isLinux && !stdenv.hostPlatform.isStatic
8, systemd
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.isLinux || stdenv.isDarwin)
18, xorg
19}:
20
21stdenv.mkDerivation rec {
22 pname = "dbus";
23 version = "1.14.0";
24
25 src = fetchurl {
26 url = "https://dbus.freedesktop.org/releases/dbus/dbus-${version}.tar.xz";
27 sha256 = "sha256-zNfM43WW4KGVWP1mSNEnKrQ/AR2AyGNa6o/QutWK69Q=";
28 };
29
30 patches = [
31 # Fix dbus-daemon crashing when running tests due to long XDG_DATA_DIRS.
32 # https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/302
33 (fetchpatch {
34 url = "https://gitlab.freedesktop.org/dbus/dbus/-/commit/b551b3e9737958216a1a9d359150a4110a9d0549.patch";
35 sha256 = "kOVjlklZzKvBZXmmrE1UiO4XWRoBLViGwdn6/eDH+DY=";
36 })
37 ] ++ (lib.optional stdenv.isSunOS ./implement-getgrouplist.patch);
38
39 postPatch = ''
40 substituteInPlace bus/Makefile.am \
41 --replace 'install-data-hook:' 'disabled:' \
42 --replace '$(mkinstalldirs) $(DESTDIR)$(localstatedir)/run/dbus' ':'
43 substituteInPlace tools/Makefile.am \
44 --replace 'install-data-local:' 'disabled:' \
45 --replace 'installcheck-local:' 'disabled:'
46 '' + /* cleanup of runtime references */ ''
47 substituteInPlace ./dbus/dbus-sysdeps-unix.c \
48 --replace 'DBUS_BINDIR "/dbus-launch"' "\"$lib/bin/dbus-launch\""
49 substituteInPlace ./tools/dbus-launch.c \
50 --replace 'DBUS_DAEMONDIR"/dbus-daemon"' '"/run/current-system/sw/bin/dbus-daemon"'
51 '';
52
53 outputs = [ "out" "dev" "lib" "doc" "man" ];
54
55 strictDeps = true;
56 nativeBuildInputs = [
57 autoreconfHook
58 autoconf-archive
59 pkg-config
60 docbook_xml_dtd_44
61 docbook-xsl-nons
62 xmlto
63 ];
64
65 propagatedBuildInputs = [
66 expat
67 ];
68
69 buildInputs =
70 lib.optionals x11Support (with xorg; [
71 libX11
72 libICE
73 libSM
74 ]) ++ lib.optional enableSystemd systemd
75 ++ lib.optionals stdenv.isLinux [ audit libapparmor ];
76 # ToDo: optional selinux?
77
78 configureFlags = [
79 "--enable-user-session"
80 "--enable-xml-docs"
81 "--libexecdir=${placeholder "out"}/libexec"
82 "--datadir=/etc"
83 "--localstatedir=/var"
84 "--runstatedir=/run"
85 "--sysconfdir=/etc"
86 "--with-session-socket-dir=/tmp"
87 "--with-system-pid-file=/run/dbus/pid"
88 "--with-system-socket=/run/dbus/system_bus_socket"
89 "--with-systemdsystemunitdir=${placeholder "out"}/etc/systemd/system"
90 "--with-systemduserunitdir=${placeholder "out"}/etc/systemd/user"
91 ] ++ lib.optional (!x11Support) "--without-x"
92 ++ lib.optionals stdenv.isLinux [ "--enable-apparmor" "--enable-libaudit" ]
93 ++ lib.optionals enableSystemd [ "SYSTEMCTL=${systemd}/bin/systemctl" ];
94
95 NIX_CFLAGS_LINK = lib.optionalString (!stdenv.isDarwin) "-Wl,--as-needed";
96
97 enableParallelBuilding = true;
98
99 doCheck = true;
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 daemon = dbus.out;
115 };
116
117 meta = with lib; {
118 description = "Simple interprocess messaging system";
119 homepage = "http://www.freedesktop.org/wiki/Software/dbus/";
120 license = licenses.gpl2Plus; # most is also under AFL-2.1
121 maintainers = teams.freedesktop.members ++ (with maintainers; [ ]);
122 platforms = platforms.unix;
123 };
124}