2023-12-28 00:15:07 +01:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2021-06-10 04:57:09 +02:00
|
|
|
, alsa-lib
|
2019-12-08 20:53:49 +01:00
|
|
|
, dbus
|
2023-12-28 00:15:07 +01:00
|
|
|
, docutils
|
2021-06-18 11:20:07 +02:00
|
|
|
, ell
|
2023-12-28 00:15:07 +01:00
|
|
|
, enableExperimental ? false
|
2024-07-04 11:40:41 +02:00
|
|
|
, fetchpatch
|
2023-12-28 00:15:07 +01:00
|
|
|
, fetchurl
|
2019-12-08 20:53:49 +01:00
|
|
|
, glib
|
|
|
|
, json_c
|
|
|
|
, libical
|
2021-01-19 07:50:56 +01:00
|
|
|
, pkg-config
|
2019-12-08 20:53:49 +01:00
|
|
|
, python3
|
|
|
|
, readline
|
2022-07-03 23:12:46 +02:00
|
|
|
, systemdMinimal
|
2019-12-08 20:53:49 +01:00
|
|
|
, udev
|
2024-08-15 10:06:52 +02:00
|
|
|
# Test gobject-introspection instead of pygobject because the latter
|
|
|
|
# causes an infinite recursion.
|
|
|
|
, gobject-introspection
|
|
|
|
, buildPackages
|
|
|
|
, installTests ? lib.meta.availableOn stdenv.hostPlatform gobject-introspection && stdenv.hostPlatform.emulatorAvailable buildPackages
|
2023-12-28 00:15:07 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2019-12-08 20:53:49 +01:00
|
|
|
pname = "bluez";
|
2024-06-24 09:47:10 +02:00
|
|
|
version = "5.76";
|
2017-09-18 20:25:02 +02:00
|
|
|
|
2009-08-05 22:29:36 +02:00
|
|
|
src = fetchurl {
|
2023-12-28 00:15:07 +01:00
|
|
|
url = "mirror://kernel/linux/bluetooth/bluez-${finalAttrs.version}.tar.xz";
|
2024-06-24 09:47:10 +02:00
|
|
|
hash = "sha256-VeLGRZCa2C2DPELOhewgQ04O8AcJQbHqtz+s3SQLvWM=";
|
2009-08-05 22:29:36 +02:00
|
|
|
};
|
|
|
|
|
2024-07-04 11:40:41 +02:00
|
|
|
patches = [
|
|
|
|
# hog-lib: Fix passing wrong parameters to bt_uhid_get_report_reply
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/bluez/bluez/commit/5ebaeab4164f80539904b9a520d9b7a8307e06e2.patch";
|
|
|
|
hash = "sha256-f1A8DmRPfm+zid4XMj1zsfcLZ0WTEax3YPbydKZF9RE=";
|
|
|
|
})
|
|
|
|
]
|
2024-02-04 17:24:06 +01:00
|
|
|
# Disable one failing test with musl libc, also seen by alpine
|
|
|
|
# https://github.com/bluez/bluez/issues/726
|
2024-07-04 11:40:41 +02:00
|
|
|
++ lib.optional (stdenv.hostPlatform.isMusl && stdenv.hostPlatform.isx86_64)
|
2024-02-04 17:24:06 +01:00
|
|
|
(fetchurl {
|
|
|
|
url = "https://git.alpinelinux.org/aports/plain/main/bluez/disable_aics_unit_testcases.patch?id=8e96f7faf01a45f0ad8449c1cd825db63a8dfd48";
|
|
|
|
hash = "sha256-1PJkipqBO3qxxOqRFQKfpWlne1kzTCgtnTFYI1cFQt4=";
|
|
|
|
})
|
|
|
|
;
|
|
|
|
|
2017-09-27 21:23:28 +02:00
|
|
|
buildInputs = [
|
2021-06-10 04:57:09 +02:00
|
|
|
alsa-lib
|
2019-12-08 20:53:49 +01:00
|
|
|
dbus
|
2021-06-18 11:20:07 +02:00
|
|
|
ell
|
2019-12-08 20:53:49 +01:00
|
|
|
glib
|
|
|
|
json_c
|
|
|
|
libical
|
|
|
|
python3
|
|
|
|
readline
|
|
|
|
udev
|
|
|
|
];
|
2009-08-05 22:29:36 +02:00
|
|
|
|
2019-12-08 20:53:49 +01:00
|
|
|
nativeBuildInputs = [
|
2021-06-17 06:38:07 +02:00
|
|
|
docutils
|
2021-01-19 07:50:56 +01:00
|
|
|
pkg-config
|
2019-12-08 20:53:49 +01:00
|
|
|
python3.pkgs.wrapPython
|
|
|
|
];
|
2018-05-01 15:57:17 +02:00
|
|
|
|
2024-08-15 10:06:52 +02:00
|
|
|
outputs = [ "out" "dev" ]
|
|
|
|
++ lib.optional installTests "test";
|
2017-09-18 20:25:02 +02:00
|
|
|
|
2019-12-08 20:53:49 +01:00
|
|
|
postPatch = ''
|
2018-05-01 15:57:17 +02:00
|
|
|
substituteInPlace tools/hid2hci.rules \
|
2022-07-03 23:12:46 +02:00
|
|
|
--replace /sbin/udevadm ${systemdMinimal}/bin/udevadm \
|
2018-05-01 15:57:17 +02:00
|
|
|
--replace "hid2hci " "$out/lib/udev/hid2hci "
|
2023-12-28 00:15:07 +01:00
|
|
|
'' +
|
|
|
|
# Disable some tests:
|
|
|
|
# - test-mesh-crypto depends on the following kernel settings:
|
|
|
|
# CONFIG_CRYPTO_[USER|USER_API|USER_API_AEAD|USER_API_HASH|AES|CCM|AEAD|CMAC]
|
|
|
|
''
|
|
|
|
if [[ ! -f unit/test-mesh-crypto.c ]]; then
|
|
|
|
echo "unit/test-mesh-crypto.c no longer exists"
|
|
|
|
false
|
|
|
|
fi
|
2021-05-14 18:36:36 +02:00
|
|
|
echo 'int main() { return 77; }' > unit/test-mesh-crypto.c
|
2018-05-01 15:57:17 +02:00
|
|
|
'';
|
2017-09-18 20:25:02 +02:00
|
|
|
|
2019-12-08 20:53:49 +01:00
|
|
|
configureFlags = [
|
2014-11-15 22:22:28 +01:00
|
|
|
"--localstatedir=/var"
|
2023-12-28 00:15:07 +01:00
|
|
|
(lib.enableFeature enableExperimental "experimental")
|
|
|
|
(lib.enableFeature true "btpclient")
|
|
|
|
(lib.enableFeature true "cups")
|
|
|
|
(lib.enableFeature true "external-ell")
|
|
|
|
(lib.enableFeature true "health")
|
|
|
|
(lib.enableFeature true "hid2hci")
|
|
|
|
(lib.enableFeature true "library")
|
|
|
|
(lib.enableFeature true "logger")
|
|
|
|
(lib.enableFeature true "mesh")
|
|
|
|
(lib.enableFeature true "midi")
|
|
|
|
(lib.enableFeature true "nfc")
|
|
|
|
(lib.enableFeature true "pie")
|
|
|
|
(lib.enableFeature true "sixaxis")
|
|
|
|
# Set "deprecated" to provide ciptool, sdptool, and rfcomm (unmaintained);
|
2021-08-15 08:39:30 +02:00
|
|
|
# superseded by new D-Bus APIs
|
2023-12-28 00:15:07 +01:00
|
|
|
(lib.enableFeature true "deprecated")
|
|
|
|
(lib.withFeatureAs true "dbusconfdir" "${placeholder "out"}/share")
|
|
|
|
(lib.withFeatureAs true "dbussessionbusdir" "${placeholder "out"}/share/dbus-1/services")
|
|
|
|
(lib.withFeatureAs true "dbussystembusdir" "${placeholder "out"}/share/dbus-1/system-services")
|
|
|
|
(lib.withFeatureAs true "systemdsystemunitdir" "${placeholder "out"}/etc/systemd/system")
|
|
|
|
(lib.withFeatureAs true "systemduserunitdir" "${placeholder "out"}/etc/systemd/user")
|
|
|
|
(lib.withFeatureAs true "udevdir" "${placeholder "out"}/lib/udev")
|
|
|
|
];
|
2021-11-26 11:47:14 +01:00
|
|
|
|
2023-12-28 00:15:07 +01:00
|
|
|
makeFlags = [
|
|
|
|
"rulesdir=${placeholder "out"}/lib/udev/rules.d"
|
|
|
|
];
|
2009-08-10 20:24:20 +02:00
|
|
|
|
|
|
|
# Work around `make install' trying to create /var/lib/bluetooth.
|
2023-12-28 00:15:07 +01:00
|
|
|
installFlags = [
|
|
|
|
"statedir=$(TMPDIR)/var/lib/bluetooth"
|
|
|
|
];
|
2011-07-07 19:23:05 +02:00
|
|
|
|
2019-12-09 01:30:39 +01:00
|
|
|
doCheck = stdenv.hostPlatform.isx86_64;
|
|
|
|
|
2023-12-28 00:15:07 +01:00
|
|
|
postInstall = let
|
|
|
|
pythonPath = with python3.pkgs; [
|
|
|
|
dbus-python
|
|
|
|
pygobject3
|
|
|
|
];
|
|
|
|
in
|
|
|
|
''
|
2017-09-18 20:25:02 +02:00
|
|
|
# for bluez4 compatibility for NixOS
|
|
|
|
mkdir $out/sbin
|
|
|
|
ln -s ../libexec/bluetooth/bluetoothd $out/sbin/bluetoothd
|
|
|
|
ln -s ../libexec/bluetooth/obexd $out/sbin/obexd
|
|
|
|
|
|
|
|
# Add extra configuration
|
2024-04-23 19:51:36 +02:00
|
|
|
rm $out/etc/bluetooth/{main,input,network}.conf
|
2017-09-18 20:25:02 +02:00
|
|
|
ln -s /etc/bluetooth/main.conf $out/etc/bluetooth/main.conf
|
2018-05-01 15:57:17 +02:00
|
|
|
|
2022-12-05 17:11:52 +01:00
|
|
|
# https://github.com/NixOS/nixpkgs/issues/204418
|
|
|
|
ln -s /etc/bluetooth/input.conf $out/etc/bluetooth/input.conf
|
|
|
|
ln -s /etc/bluetooth/network.conf $out/etc/bluetooth/network.conf
|
|
|
|
|
2018-05-01 15:57:17 +02:00
|
|
|
# Add missing tools, ref https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/bluez
|
2023-12-28 00:15:07 +01:00
|
|
|
for files in $(find tools/ -type f -perm -755); do
|
2018-05-01 15:57:17 +02:00
|
|
|
filename=$(basename $files)
|
|
|
|
install -Dm755 tools/$filename $out/bin/$filename
|
|
|
|
done
|
2022-04-23 12:44:50 +02:00
|
|
|
install -Dm755 attrib/gatttool $out/bin/gatttool
|
2024-08-15 10:06:52 +02:00
|
|
|
'' + lib.optionalString installTests ''
|
|
|
|
mkdir -p $test/{bin,test}
|
|
|
|
cp -a test $test
|
|
|
|
pushd $test/test
|
|
|
|
for t in \
|
|
|
|
list-devices \
|
|
|
|
monitor-bluetooth \
|
|
|
|
simple-agent \
|
|
|
|
test-adapter \
|
|
|
|
test-device \
|
|
|
|
test-thermometer \
|
|
|
|
; do
|
|
|
|
ln -s ../test/$t $test/bin/bluez-$t
|
|
|
|
done
|
|
|
|
popd
|
|
|
|
wrapPythonProgramsIn $test/test "$test/test ${toString pythonPath}"
|
2011-05-21 00:21:34 +02:00
|
|
|
'';
|
|
|
|
|
2017-09-18 20:25:02 +02:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2023-12-28 00:15:07 +01:00
|
|
|
meta = {
|
|
|
|
homepage = "https://www.bluez.org/";
|
|
|
|
description = "Official Linux Bluetooth protocol stack";
|
|
|
|
changelog = "https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/ChangeLog?h=${finalAttrs.version}";
|
|
|
|
license = with lib.licenses; [ bsd2 gpl2Plus lgpl21Plus mit ];
|
|
|
|
mainProgram = "btinfo";
|
|
|
|
maintainers = with lib.maintainers; [ AndersonTorres ];
|
|
|
|
platforms = lib.platforms.linux;
|
2009-08-05 22:29:36 +02:00
|
|
|
};
|
2023-12-28 00:15:07 +01:00
|
|
|
})
|