summaryrefslogtreecommitdiffstats
path: root/pkgs/development/libraries/libusb-compat/0.1.nix
blob: dd48ccd86fc57701b265c0c11d8abd1114565d25 (plain)
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
52
53
{
  stdenv,
  lib,
  fetchFromGitHub,
  autoreconfHook,
  pkg-config,
  libusb1,
}:

stdenv.mkDerivation rec {
  pname = "libusb-compat";
  version = "0.1.8";

  outputs = [
    "out"
    "dev"
  ]; # get rid of propagating systemd closure
  outputBin = "dev";

  src = fetchFromGitHub {
    owner = "libusb";
    repo = "libusb-compat-0.1";
    rev = "v${version}";
    sha256 = "sha256-pAPERYSxoc47gwpPUoMkrbK8TOXyx03939vlFN0hHRg=";
  };

  patches = lib.optional stdenv.hostPlatform.isMusl ./fix-headers.patch;

  nativeBuildInputs = [
    autoreconfHook
    pkg-config
  ];

  buildInputs = [ libusb1 ];

  # without this, libusb-compat is unable to find libusb1
  postFixup = ''
    find $out/lib -name \*.so\* -type f -exec \
      patchelf --set-rpath ${lib.makeLibraryPath buildInputs} {} \;
  '';

  meta = {
    homepage = "https://libusb.info/";
    description = "Cross-platform user-mode USB device library";
    mainProgram = "libusb-config";
    longDescription = ''
      libusb is a cross-platform user-mode library that provides access to USB devices.
      The current API is of 1.0 version (libusb-1.0 API), this library is a wrapper exposing the legacy API.
    '';
    license = lib.licenses.lgpl2Plus;
    platforms = lib.platforms.unix;
  };
}