nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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 libcap_ng,
11 libapparmor,
12 dbus,
13 docbook_xml_dtd_44,
14 docbook-xsl-nons,
15 libxslt,
16 meson,
17 ninja,
18 python3,
19 x11Support ? (stdenv.hostPlatform.isLinux || stdenv.hostPlatform.isDarwin),
20 writeText,
21 libx11,
22 libsm,
23 libice,
24}:
25
26stdenv.mkDerivation (finalAttrs: {
27 pname = "dbus";
28 version = "1.16.2";
29
30 outputs = [
31 "out"
32 "dev"
33 "lib"
34 "doc"
35 "man"
36 ];
37
38 separateDebugInfo = true;
39
40 src = fetchurl {
41 url = "https://dbus.freedesktop.org/releases/dbus/dbus-${finalAttrs.version}.tar.xz";
42 sha256 = "sha256-C6KhpLFq/nvOssB+nOmajCw1COXewpDbtkM4S9a+t+I=";
43 };
44
45 patches = [
46 # Implement getgrouplist for platforms where it is not available (e.g. Illumos/Solaris)
47 ./implement-getgrouplist.patch
48
49 # Add a Meson configuration option that will allow us to use a different
50 # `datadir` for installation from the one that will be compiled into dbus.
51 # This is necessary to allow NixOS to manage dbus service definitions,
52 # since the `datadir` in the package will be immutable. But we still want
53 # to install the files to the latter, since there is no other suitable
54 # place for the project to install them.
55 #
56 # We will also just remove installation of empty `${runstatedir}/dbus`
57 # and `${localstatedir}/lib/dbus` since these are useless in the package.
58 ./meson-install-dirs.patch
59 ];
60
61 strictDeps = true;
62
63 nativeBuildInputs = [
64 meson
65 ninja
66 pkg-config
67 docbook_xml_dtd_44
68 docbook-xsl-nons
69 libxslt # for xsltproc
70 python3
71 ];
72
73 buildInputs = [
74 expat
75 ]
76 ++ lib.optionals x11Support [
77 libx11
78 libice
79 libsm
80 ]
81 ++ lib.optional enableSystemd systemdMinimal
82 ++ lib.optionals stdenv.hostPlatform.isLinux [
83 audit
84 libapparmor
85 libcap_ng
86 ];
87 # ToDo: optional selinux?
88
89 __darwinAllowLocalNetworking = true;
90
91 mesonFlags = [
92 "--libexecdir=${placeholder "out"}/libexec"
93 # datadir from which dbus will load files will be managed by the NixOS module:
94 "--datadir=/etc"
95 # But we still want to install stuff to the package:
96 "-Dinstall_datadir=${placeholder "out"}/share"
97 "--localstatedir=/var"
98 "-Druntime_dir=/run"
99 "--sysconfdir=/etc"
100 "-Dinstall_sysconfdir=${placeholder "out"}/etc"
101 "-Ddoxygen_docs=disabled"
102 "-Dducktype_docs=disabled"
103 "-Dlaunchd_agent_dir=${placeholder "out"}/Library/LaunchAgents"
104 "-Dqt_help=disabled"
105 "-Drelocation=disabled" # Conflicts with multiple outputs
106 "-Dmodular_tests=disabled" # Requires glib
107 "-Dsession_socket_dir=/tmp"
108 "-Dsystemd_system_unitdir=${placeholder "out"}/etc/systemd/system"
109 "-Dsystemd_user_unitdir=${placeholder "out"}/etc/systemd/user"
110 (lib.mesonEnable "x11_autolaunch" x11Support)
111 (lib.mesonEnable "apparmor" stdenv.hostPlatform.isLinux)
112 (lib.mesonEnable "epoll" stdenv.hostPlatform.isLinux)
113 (lib.mesonEnable "inotify" stdenv.hostPlatform.isLinux)
114 (lib.mesonEnable "libaudit" stdenv.hostPlatform.isLinux)
115 (lib.mesonEnable "kqueue" (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isBSD))
116 (lib.mesonEnable "launchd" stdenv.hostPlatform.isDarwin)
117 (lib.mesonEnable "systemd" enableSystemd)
118 "-Dselinux=disabled"
119 ]
120 ++ lib.optionals stdenv.hostPlatform.isDarwin [
121 # `launchctl` is only needed at runtime. Lie to `find_program` because it will always be present on a Darwin host.
122 "--cross-file=${writeText "darwin.ini" ''
123 [binaries]
124 launchctl = 'true'
125 ''}"
126 ]
127 ++ lib.optionals enableSystemd [
128 "--cross-file=${writeText "crossfile.ini" ''
129 [binaries]
130 systemctl = '${systemdMinimal}/bin/systemctl'
131 ''}"
132 ];
133
134 doCheck = true;
135
136 postPatch = ''
137 patchShebangs \
138 test/data/copy_data_for_tests.py \
139 meson_post_install.py
140
141 # Cleanup of runtime references
142 substituteInPlace ./dbus/dbus-sysdeps-unix.c \
143 --replace-fail 'DBUS_BINDIR "/dbus-launch"' "\"$lib/bin/dbus-launch\""
144 substituteInPlace ./tools/dbus-launch.c \
145 --replace-fail 'DBUS_DAEMONDIR"/dbus-daemon"' '"/run/current-system/sw/bin/dbus-daemon"'
146 '';
147
148 postFixup = ''
149 # It's executed from $lib by absolute path
150 moveToOutput bin/dbus-launch "$lib"
151 ln -s "$lib/bin/dbus-launch" "$out/bin/"
152 '';
153
154 passthru = {
155 dbus-launch = "${dbus.lib}/bin/dbus-launch";
156 };
157
158 meta = {
159 description = "Simple interprocess messaging system";
160 homepage = "https://www.freedesktop.org/wiki/Software/dbus/";
161 changelog = "https://gitlab.freedesktop.org/dbus/dbus/-/blob/dbus-${finalAttrs.version}/NEWS";
162 license = lib.licenses.gpl2Plus; # most is also under AFL-2.1
163 teams = [ lib.teams.freedesktop ];
164 platforms = lib.platforms.unix;
165 };
166})