1{ lib, stdenv
2, fetchFromGitHub
3, fetchpatch
4, autoreconfHook
5, pkg-config
6, enableUdev ? stdenv.isLinux && !stdenv.targetPlatform.isStatic
7, udev
8, libobjc
9, IOKit
10, Security
11, withStatic ? false
12}:
13
14stdenv.mkDerivation rec {
15 pname = "libusb";
16 version = "1.0.26";
17
18 src = fetchFromGitHub {
19 owner = "libusb";
20 repo = "libusb";
21 rev = "v${version}";
22 sha256 = "sha256-LEy45YiFbueCCi8d2hguujMsxBezaTUERHUpFsTKGZQ=";
23 };
24
25 outputs = [ "out" "dev" ];
26
27 nativeBuildInputs = [ pkg-config autoreconfHook ];
28 propagatedBuildInputs =
29 lib.optional enableUdev udev ++
30 lib.optionals stdenv.isDarwin [ libobjc IOKit Security ];
31
32 dontDisableStatic = withStatic;
33
34 configureFlags = lib.optional (!enableUdev) "--disable-udev";
35
36 preFixup = lib.optionalString enableUdev ''
37 sed 's,-ludev,-L${lib.getLib udev}/lib -ludev,' -i $out/lib/libusb-1.0.la
38 '';
39
40 meta = with lib; {
41 homepage = "https://libusb.info/";
42 description = "cross-platform user-mode USB device library";
43 longDescription = ''
44 libusb is a cross-platform user-mode library that provides access to USB devices.
45 '';
46 platforms = platforms.all;
47 license = licenses.lgpl21Plus;
48 maintainers = with maintainers; [ prusnak ];
49 };
50}