nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 196 lines 5.4 kB view raw
1{ 2 lib, 3 stdenv, 4 alsa-lib, 5 autoreconfHook, 6 bluez-headers, 7 dbus, 8 docutils, 9 ell, 10 enableExperimental ? false, 11 fetchurl, 12 glib, 13 json_c, 14 libical, 15 pkg-config, 16 python3Packages, 17 readline, 18 udev, 19 # Test gobject-introspection instead of pygobject because the latter 20 # causes an infinite recursion. 21 gobject-introspection, 22 buildPackages, 23 installTests ? 24 lib.meta.availableOn stdenv.hostPlatform gobject-introspection 25 && stdenv.hostPlatform.emulatorAvailable buildPackages, 26 gitUpdater, 27 udevCheckHook, 28}: 29 30stdenv.mkDerivation (finalAttrs: { 31 pname = "bluez"; 32 inherit (bluez-headers) version src; 33 34 patches = [ 35 (fetchurl { 36 name = "static.patch"; 37 url = "https://lore.kernel.org/linux-bluetooth/20250703182908.2370130-1-hi@alyssa.is/raw"; 38 hash = "sha256-4Yz3ljsn2emJf+uTcJO4hG/YXvjERtitce71TZx5Hak="; 39 }) 40 ]; 41 42 buildInputs = [ 43 alsa-lib 44 dbus 45 ell 46 glib 47 json_c 48 libical 49 python3Packages.python 50 readline 51 udev 52 ]; 53 54 nativeBuildInputs = [ 55 autoreconfHook 56 docutils 57 pkg-config 58 python3Packages.pygments 59 python3Packages.wrapPython 60 udevCheckHook 61 ]; 62 63 outputs = [ 64 "out" 65 "dev" 66 ] 67 ++ lib.optional installTests "test"; 68 69 postPatch = '' 70 substituteInPlace tools/hid2hci.rules \ 71 --replace-fail /sbin/udevadm ${udev}/bin/udevadm \ 72 --replace-fail "hid2hci " "$out/lib/udev/hid2hci " 73 '' 74 + 75 # Disable some tests: 76 # - test-mesh-crypto depends on the following kernel settings: 77 # CONFIG_CRYPTO_[USER|USER_API|USER_API_AEAD|USER_API_HASH|AES|CCM|AEAD|CMAC] 78 # - test-vcp is flaky (?), see: 79 # - https://github.com/bluez/bluez/issues/683 80 # - https://github.com/bluez/bluez/issues/726 81 '' 82 skipTest() { 83 if [[ ! -f unit/$1.c ]]; then 84 echo "unit/$1.c no longer exists" 85 false 86 fi 87 88 echo 'int main() { return 77; }' > unit/$1.c 89 } 90 91 skipTest test-mesh-crypto 92 skipTest test-vcp 93 ''; 94 95 configureFlags = [ 96 "--localstatedir=/var" 97 (lib.enableFeature enableExperimental "experimental") 98 (lib.enableFeature true "btpclient") 99 (lib.enableFeature true "cups") 100 (lib.enableFeature true "external-ell") 101 (lib.enableFeature true "health") 102 (lib.enableFeature true "hid2hci") 103 (lib.enableFeature true "library") 104 (lib.enableFeature true "logger") 105 (lib.enableFeature true "mesh") 106 (lib.enableFeature true "midi") 107 (lib.enableFeature true "nfc") 108 (lib.enableFeature true "pie") 109 (lib.enableFeature true "sixaxis") 110 (lib.enableFeature (lib.elem "libsystemd" udev.meta.pkgConfigModules) "systemd") 111 # Set "deprecated" to provide ciptool, sdptool, and rfcomm (unmaintained); 112 # superseded by new D-Bus APIs 113 (lib.enableFeature true "deprecated") 114 (lib.withFeatureAs true "dbusconfdir" "${placeholder "out"}/share") 115 (lib.withFeatureAs true "dbussessionbusdir" "${placeholder "out"}/share/dbus-1/services") 116 (lib.withFeatureAs true "dbussystembusdir" "${placeholder "out"}/share/dbus-1/system-services") 117 (lib.withFeatureAs true "systemdsystemunitdir" "${placeholder "out"}/etc/systemd/system") 118 (lib.withFeatureAs true "systemduserunitdir" "${placeholder "out"}/etc/systemd/user") 119 (lib.withFeatureAs true "udevdir" "${placeholder "out"}/lib/udev") 120 ]; 121 122 makeFlags = [ 123 "rulesdir=${placeholder "out"}/lib/udev/rules.d" 124 ]; 125 126 # Work around `make install' trying to create /var/lib/bluetooth. 127 installFlags = [ 128 "statedir=$(TMPDIR)/var/lib/bluetooth" 129 ]; 130 131 doCheck = stdenv.hostPlatform.isx86_64; 132 doInstallCheck = true; 133 134 postInstall = 135 let 136 pythonPath = with python3Packages; [ 137 dbus-python 138 pygobject3 139 ]; 140 in 141 '' 142 # for bluez4 compatibility for NixOS 143 mkdir $out/sbin 144 ln -s ../libexec/bluetooth/bluetoothd $out/sbin/bluetoothd 145 ln -s ../libexec/bluetooth/obexd $out/sbin/obexd 146 147 # Add extra configuration 148 rm $out/etc/bluetooth/{main,input,network}.conf 149 ln -s /etc/bluetooth/main.conf $out/etc/bluetooth/main.conf 150 151 # https://github.com/NixOS/nixpkgs/issues/204418 152 ln -s /etc/bluetooth/input.conf $out/etc/bluetooth/input.conf 153 ln -s /etc/bluetooth/network.conf $out/etc/bluetooth/network.conf 154 155 # Add missing tools, ref https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/bluez 156 for files in $(find tools/ -type f -perm -755); do 157 filename=$(basename $files) 158 install -Dm755 tools/$filename $out/bin/$filename 159 done 160 install -Dm755 attrib/gatttool $out/bin/gatttool 161 '' 162 + lib.optionalString installTests '' 163 mkdir -p $test/{bin,test} 164 cp -a test $test 165 pushd $test/test 166 for t in \ 167 list-devices \ 168 monitor-bluetooth \ 169 simple-agent \ 170 test-adapter \ 171 test-device \ 172 ; do 173 ln -s ../test/$t $test/bin/bluez-$t 174 done 175 popd 176 wrapPythonProgramsIn $test/test "$test/test ${toString pythonPath}" 177 ''; 178 179 enableParallelBuilding = true; 180 181 passthru.updateScript = gitUpdater { 182 url = "https://git.kernel.org/pub/scm/bluetooth/bluez.git"; 183 }; 184 185 meta = { 186 mainProgram = "btinfo"; 187 inherit (bluez-headers.meta) 188 changelog 189 description 190 homepage 191 license 192 maintainers 193 platforms 194 ; 195 }; 196})