summary refs log tree commit diff
path: root/pkgs/development/libraries/libusb1/default.nix
blob: 10310e22da7be4d56374d3857158f71e04b32bcd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{ stdenv
, fetchFromGitHub
, autoreconfHook
, pkgconfig
, enableUdev ? stdenv.isLinux && !stdenv.hostPlatform.isMusl
, udev ? null
, libobjc
, IOKit
, withStatic ? false
}:

assert enableUdev -> udev != null;

stdenv.mkDerivation rec {
  pname = "libusb";
  version = "1.0.24";

  src = fetchFromGitHub {
    owner = "libusb";
    repo = "libusb";
    rev = "v${version}";
    sha256 = "18ri8ky422hw64zry7bpbarb1m0hiljyf64a0a9y093y7aad38i7";
  };

  outputs = [ "out" "dev" ];

  nativeBuildInputs = [ pkgconfig autoreconfHook ];
  propagatedBuildInputs =
    stdenv.lib.optional enableUdev udev ++
    stdenv.lib.optionals stdenv.isDarwin [ libobjc IOKit ];

  dontDisableStatic = withStatic;

  configureFlags = stdenv.lib.optional (!enableUdev) "--disable-udev";

  preFixup = stdenv.lib.optionalString enableUdev ''
    sed 's,-ludev,-L${stdenv.lib.getLib udev}/lib -ludev,' -i $out/lib/libusb-1.0.la
  '';

  meta = with stdenv.lib; {
    homepage = "https://libusb.info/";
    repositories.git = "https://github.com/libusb/libusb";
    description = "cross-platform user-mode USB device library";
    longDescription = ''
      libusb is a cross-platform user-mode library that provides access to USB devices.
    '';
    platforms = platforms.all;
    license = licenses.lgpl21Plus;
    maintainers = with maintainers; [ prusnak ];
  };
}