Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 autoreconfHook, 6 doxygen, 7 pkg-config, 8 enableUdev ? 9 stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isStatic && !stdenv.hostPlatform.isAndroid, 10 udev, 11 udevCheckHook, 12 withExamples ? false, 13 withStatic ? false, 14 withDocs ? stdenv.buildPlatform.canExecute stdenv.hostPlatform, 15}: 16 17stdenv.mkDerivation rec { 18 pname = "libusb"; 19 version = "1.0.29"; 20 21 src = fetchFromGitHub { 22 owner = "libusb"; 23 repo = "libusb"; 24 rev = "v${version}"; 25 sha256 = "sha256-m1w+uF8+2WCn72LvoaGUYa+R0PyXHtFFONQjdRfImYY="; 26 }; 27 28 outputs = [ 29 "out" 30 "dev" 31 ] 32 ++ lib.optionals withDocs [ "doc" ]; 33 34 nativeBuildInputs = [ 35 pkg-config 36 autoreconfHook 37 ] 38 ++ lib.optionals withDocs [ doxygen ]; 39 propagatedBuildInputs = lib.optional enableUdev udev; 40 41 # Many dependents are dealing with hardware devices, exposing udev rules for them. 42 # Checking these by propagated hook might improve discoverability 43 propagatedNativeBuildInputs = lib.optional enableUdev udevCheckHook; 44 45 dontDisableStatic = withStatic; 46 47 # libusb-1.0.rc:11: fatal error: opening dependency file .deps/libusb-1.0.Tpo: No such file or directory 48 dontAddDisableDepTrack = stdenv.hostPlatform.isWindows; 49 50 configureFlags = 51 lib.optional (!enableUdev) "--disable-udev" 52 ++ lib.optional (withExamples) "--enable-examples-build"; 53 54 postBuild = lib.optionalString withDocs '' 55 make -C doc 56 mkdir -p "$doc/share/doc/libusb" 57 cp -r doc/api-1.0/* "$doc/share/doc/libusb/" 58 ''; 59 60 preFixup = lib.optionalString enableUdev '' 61 sed 's,-ludev,-L${lib.getLib udev}/lib -ludev,' -i $out/lib/libusb-1.0.la 62 ''; 63 64 postInstall = lib.optionalString withExamples '' 65 mkdir -p $out/{bin,sbin,examples/bin} 66 cp -r examples/.libs/* $out/examples/bin 67 ln -s $out/examples/bin/fxload $out/sbin/fxload 68 ''; 69 70 meta = with lib; { 71 homepage = "https://libusb.info/"; 72 description = "Cross-platform user-mode USB device library"; 73 longDescription = '' 74 libusb is a cross-platform user-mode library that provides access to USB devices. 75 ''; 76 platforms = platforms.all; 77 license = licenses.lgpl21Plus; 78 maintainers = with maintainers; [ 79 prusnak 80 realsnick 81 ]; 82 }; 83}