at 24.05-pre 152 lines 4.2 kB view raw
1{ stdenv 2, lib 3, fetchurl 4, fetchpatch 5, alsa-lib 6, dbus 7, ell 8, glib 9, json_c 10, libical 11, docutils 12, pkg-config 13, python3 14, readline 15, systemdMinimal 16, udev 17, withExperimental ? false 18}: let 19 pythonPath = with python3.pkgs; [ 20 dbus-python 21 pygobject3 22 recursivePthLoader 23 ]; 24in stdenv.mkDerivation rec { 25 pname = "bluez"; 26 version = "5.70"; 27 28 src = fetchurl { 29 url = "mirror://kernel/linux/bluetooth/${pname}-${version}.tar.xz"; 30 sha256 = "sha256-N+Ny6RaVXhRMuIL4iOS+QImPEK47fCE93N1V7pwAkng="; 31 }; 32 33 patches = [ 34 # replace use of a non-standard symbol to fix build with musl libc (pkgsMusl.bluez) 35 (fetchpatch { 36 url = "https://git.alpinelinux.org/aports/plain/main/bluez/max-input.patch?id=32b31b484cb13009bd8081c4106e4cf064ec2f1f"; 37 sha256 = "sha256-SczbXtsxBkCO+izH8XOBcrJEO2f7MdtYVT3+2fCV8wU="; 38 }) 39 ]; 40 41 buildInputs = [ 42 alsa-lib 43 dbus 44 ell 45 glib 46 json_c 47 libical 48 python3 49 readline 50 udev 51 ]; 52 53 nativeBuildInputs = [ 54 docutils 55 pkg-config 56 python3.pkgs.wrapPython 57 ]; 58 59 outputs = [ "out" "dev" "test" ]; 60 61 postPatch = '' 62 substituteInPlace tools/hid2hci.rules \ 63 --replace /sbin/udevadm ${systemdMinimal}/bin/udevadm \ 64 --replace "hid2hci " "$out/lib/udev/hid2hci " 65 # Disable some tests: 66 # - test-mesh-crypto depends on the following kernel settings: 67 # CONFIG_CRYPTO_[USER|USER_API|USER_API_AEAD|USER_API_HASH|AES|CCM|AEAD|CMAC] 68 if [[ ! -f unit/test-mesh-crypto.c ]]; then echo "unit/test-mesh-crypto.c no longer exists"; false; fi 69 echo 'int main() { return 77; }' > unit/test-mesh-crypto.c 70 ''; 71 72 configureFlags = [ 73 "--localstatedir=/var" 74 "--enable-library" 75 "--enable-cups" 76 "--enable-pie" 77 "--enable-external-ell" 78 "--with-dbusconfdir=${placeholder "out"}/share" 79 "--with-dbussystembusdir=${placeholder "out"}/share/dbus-1/system-services" 80 "--with-dbussessionbusdir=${placeholder "out"}/share/dbus-1/services" 81 "--with-systemdsystemunitdir=${placeholder "out"}/etc/systemd/system" 82 "--with-systemduserunitdir=${placeholder "out"}/etc/systemd/user" 83 "--with-udevdir=${placeholder "out"}/lib/udev" 84 "--enable-health" 85 "--enable-mesh" 86 "--enable-midi" 87 "--enable-nfc" 88 "--enable-sixaxis" 89 "--enable-btpclient" 90 "--enable-hid2hci" 91 "--enable-logger" 92 93 # To provide ciptool, sdptool, and rfcomm (unmaintained) 94 # superseded by new D-Bus APIs 95 "--enable-deprecated" 96 ] ++ lib.optional withExperimental "--enable-experimental"; 97 98 99 # Work around `make install' trying to create /var/lib/bluetooth. 100 installFlags = [ "statedir=$(TMPDIR)/var/lib/bluetooth" ]; 101 102 makeFlags = [ "rulesdir=${placeholder "out"}/lib/udev/rules.d" ]; 103 104 doCheck = stdenv.hostPlatform.isx86_64; 105 106 postInstall = '' 107 mkdir -p $test/{bin,test} 108 cp -a test $test 109 pushd $test/test 110 for a in \ 111 simple-agent \ 112 test-adapter \ 113 test-device \ 114 test-thermometer \ 115 list-devices \ 116 monitor-bluetooth \ 117 ; do 118 ln -s ../test/$a $test/bin/bluez-$a 119 done 120 popd 121 wrapPythonProgramsIn $test/test "$test/test ${toString pythonPath}" 122 '' + '' 123 # for bluez4 compatibility for NixOS 124 mkdir $out/sbin 125 ln -s ../libexec/bluetooth/bluetoothd $out/sbin/bluetoothd 126 ln -s ../libexec/bluetooth/obexd $out/sbin/obexd 127 128 # Add extra configuration 129 mkdir $out/etc/bluetooth 130 ln -s /etc/bluetooth/main.conf $out/etc/bluetooth/main.conf 131 132 # https://github.com/NixOS/nixpkgs/issues/204418 133 ln -s /etc/bluetooth/input.conf $out/etc/bluetooth/input.conf 134 ln -s /etc/bluetooth/network.conf $out/etc/bluetooth/network.conf 135 136 # Add missing tools, ref https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/bluez 137 for files in `find tools/ -type f -perm -755`; do 138 filename=$(basename $files) 139 install -Dm755 tools/$filename $out/bin/$filename 140 done 141 install -Dm755 attrib/gatttool $out/bin/gatttool 142 ''; 143 144 enableParallelBuilding = true; 145 146 meta = with lib; { 147 description = "Bluetooth support for Linux"; 148 homepage = "http://www.bluez.org/"; 149 license = with licenses; [ gpl2 lgpl21 ]; 150 platforms = platforms.linux; 151 }; 152}