7 , enableExperimental ? false
18 # Test gobject-introspection instead of pygobject because the latter
19 # causes an infinite recursion.
20 , gobject-introspection
22 , installTests ? lib.meta.availableOn stdenv.hostPlatform gobject-introspection && stdenv.hostPlatform.emulatorAvailable buildPackages
25 stdenv.mkDerivation (finalAttrs: {
30 url = "mirror://kernel/linux/bluetooth/bluez-${finalAttrs.version}.tar.xz";
31 hash = "sha256-gw/tGRXF03W43g9eb0X83qDcxf9f+z0x227Q8A1zxeM=";
35 # Upstream fix is wrong:
36 # https://github.com/bluez/bluez/issues/843#issuecomment-2352696535
38 name = "basename.patch";
39 url = "https://github.com/void-linux/void-packages/raw/187b45d47d93b6857a95cae10c2132d76e4955fc/srcpkgs/bluez/patches/basename.patch";
40 hash = "sha256-Jb4u7rxIShDp1yUgaQVDJo2HJfZBzRoVlcDEWxooFgk=";
42 ] ++ lib.optional (stdenv.hostPlatform.isMusl && stdenv.hostPlatform.isx86_64)
43 # Disable one failing test with musl libc, also seen by alpine
44 # https://github.com/bluez/bluez/issues/726
46 url = "https://git.alpinelinux.org/aports/plain/main/bluez/disable_aics_unit_testcases.patch?id=8e96f7faf01a45f0ad8449c1cd825db63a8dfd48";
47 hash = "sha256-1PJkipqBO3qxxOqRFQKfpWlne1kzTCgtnTFYI1cFQt4=";
57 python3Packages.python
65 python3Packages.pygments
66 python3Packages.wrapPython
69 outputs = [ "out" "dev" ]
70 ++ lib.optional installTests "test";
73 substituteInPlace tools/hid2hci.rules \
74 --replace-fail /sbin/udevadm ${systemdMinimal}/bin/udevadm \
75 --replace-fail "hid2hci " "$out/lib/udev/hid2hci "
78 # - test-mesh-crypto depends on the following kernel settings:
79 # CONFIG_CRYPTO_[USER|USER_API|USER_API_AEAD|USER_API_HASH|AES|CCM|AEAD|CMAC]
81 if [[ ! -f unit/test-mesh-crypto.c ]]; then
82 echo "unit/test-mesh-crypto.c no longer exists"
85 echo 'int main() { return 77; }' > unit/test-mesh-crypto.c
89 "--localstatedir=/var"
90 (lib.enableFeature enableExperimental "experimental")
91 (lib.enableFeature true "btpclient")
92 (lib.enableFeature true "cups")
93 (lib.enableFeature true "external-ell")
94 (lib.enableFeature true "health")
95 (lib.enableFeature true "hid2hci")
96 (lib.enableFeature true "library")
97 (lib.enableFeature true "logger")
98 (lib.enableFeature true "mesh")
99 (lib.enableFeature true "midi")
100 (lib.enableFeature true "nfc")
101 (lib.enableFeature true "pie")
102 (lib.enableFeature true "sixaxis")
103 # Set "deprecated" to provide ciptool, sdptool, and rfcomm (unmaintained);
104 # superseded by new D-Bus APIs
105 (lib.enableFeature true "deprecated")
106 (lib.withFeatureAs true "dbusconfdir" "${placeholder "out"}/share")
107 (lib.withFeatureAs true "dbussessionbusdir" "${placeholder "out"}/share/dbus-1/services")
108 (lib.withFeatureAs true "dbussystembusdir" "${placeholder "out"}/share/dbus-1/system-services")
109 (lib.withFeatureAs true "systemdsystemunitdir" "${placeholder "out"}/etc/systemd/system")
110 (lib.withFeatureAs true "systemduserunitdir" "${placeholder "out"}/etc/systemd/user")
111 (lib.withFeatureAs true "udevdir" "${placeholder "out"}/lib/udev")
115 "rulesdir=${placeholder "out"}/lib/udev/rules.d"
118 # Work around `make install' trying to create /var/lib/bluetooth.
120 "statedir=$(TMPDIR)/var/lib/bluetooth"
123 doCheck = stdenv.hostPlatform.isx86_64;
126 pythonPath = with python3Packages; [
132 # for bluez4 compatibility for NixOS
134 ln -s ../libexec/bluetooth/bluetoothd $out/sbin/bluetoothd
135 ln -s ../libexec/bluetooth/obexd $out/sbin/obexd
137 # Add extra configuration
138 rm $out/etc/bluetooth/{main,input,network}.conf
139 ln -s /etc/bluetooth/main.conf $out/etc/bluetooth/main.conf
141 # https://github.com/NixOS/nixpkgs/issues/204418
142 ln -s /etc/bluetooth/input.conf $out/etc/bluetooth/input.conf
143 ln -s /etc/bluetooth/network.conf $out/etc/bluetooth/network.conf
145 # Add missing tools, ref https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/bluez
146 for files in $(find tools/ -type f -perm -755); do
147 filename=$(basename $files)
148 install -Dm755 tools/$filename $out/bin/$filename
150 install -Dm755 attrib/gatttool $out/bin/gatttool
151 '' + lib.optionalString installTests ''
152 mkdir -p $test/{bin,test}
163 ln -s ../test/$t $test/bin/bluez-$t
166 wrapPythonProgramsIn $test/test "$test/test ${toString pythonPath}"
169 enableParallelBuilding = true;
172 homepage = "https://www.bluez.org/";
173 description = "Official Linux Bluetooth protocol stack";
174 changelog = "https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/ChangeLog?h=${finalAttrs.version}";
175 license = with lib.licenses; [ bsd2 gpl2Plus lgpl21Plus mit ];
176 mainProgram = "btinfo";
177 maintainers = with lib.maintainers; [ ];
178 platforms = lib.platforms.linux;