nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib, stdenv
2, fetchFromGitHub
3, fetchpatch
4, autoreconfHook
5, pkg-config
6, enableUdev ? stdenv.isLinux && !stdenv.hostPlatform.isMusl
7, udev
8, libobjc
9, IOKit
10, withStatic ? false
11}:
12
13stdenv.mkDerivation rec {
14 pname = "libusb";
15 version = "1.0.24";
16
17 src = fetchFromGitHub {
18 owner = "libusb";
19 repo = "libusb";
20 rev = "v${version}";
21 sha256 = "18ri8ky422hw64zry7bpbarb1m0hiljyf64a0a9y093y7aad38i7";
22 };
23
24 outputs = [ "out" "dev" ];
25
26 patches = [ (fetchpatch {
27 # https://bugs.archlinux.org/task/69121
28 url = "https://github.com/libusb/libusb/commit/f6d2cb561402c3b6d3627c0eb89e009b503d9067.patch";
29 sha256 = "1dbahikcbwkjhyvks7wbp7fy2bf7nca48vg5z0zqvqzjb9y595cq";
30 excludes = [ "libusb/version_nano.h" ];
31 }) ];
32
33 nativeBuildInputs = [ pkg-config autoreconfHook ];
34 propagatedBuildInputs =
35 lib.optional enableUdev udev ++
36 lib.optionals stdenv.isDarwin [ libobjc IOKit ];
37
38 dontDisableStatic = withStatic;
39
40 configureFlags = lib.optional (!enableUdev) "--disable-udev";
41
42 preFixup = lib.optionalString enableUdev ''
43 sed 's,-ludev,-L${lib.getLib udev}/lib -ludev,' -i $out/lib/libusb-1.0.la
44 '';
45
46 meta = with lib; {
47 homepage = "https://libusb.info/";
48 repositories.git = "https://github.com/libusb/libusb";
49 description = "cross-platform user-mode USB device library";
50 longDescription = ''
51 libusb is a cross-platform user-mode library that provides access to USB devices.
52 '';
53 platforms = platforms.all;
54 license = licenses.lgpl21Plus;
55 maintainers = with maintainers; [ prusnak ];
56 };
57}