about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/libusb-compat
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/libusb-compat')
-rw-r--r--nixpkgs/pkgs/development/libraries/libusb-compat/0.1.nix46
-rw-r--r--nixpkgs/pkgs/development/libraries/libusb-compat/fix-headers.patch10
2 files changed, 56 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/libusb-compat/0.1.nix b/nixpkgs/pkgs/development/libraries/libusb-compat/0.1.nix
new file mode 100644
index 000000000000..f977d72e7242
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/libusb-compat/0.1.nix
@@ -0,0 +1,46 @@
+{ stdenv
+, lib
+, fetchFromGitHub
+, autoreconfHook
+, patchelf
+, pkg-config
+, libusb1
+}:
+
+stdenv.mkDerivation rec {
+  pname = "libusb-compat";
+  version = "0.1.7";
+
+  outputs = [ "out" "dev" ]; # get rid of propagating systemd closure
+  outputBin = "dev";
+
+  nativeBuildInputs = [ autoreconfHook patchelf pkg-config ];
+
+  buildInputs = [ libusb1 ];
+
+  src = fetchFromGitHub {
+    owner = "libusb";
+    repo = "libusb-compat-0.1";
+    rev = "v${version}";
+    sha256 = "1nybccgjs14b3phhaycq2jx1gym4nf6sghvnv9qdfmlqxacx0jz5";
+  };
+
+  patches = lib.optional stdenv.hostPlatform.isMusl ./fix-headers.patch;
+
+  # 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 = with lib; {
+    homepage = "https://libusb.info/";
+    description = "cross-platform user-mode USB device library";
+    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 = licenses.lgpl2Plus;
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/libusb-compat/fix-headers.patch b/nixpkgs/pkgs/development/libraries/libusb-compat/fix-headers.patch
new file mode 100644
index 000000000000..ea9cbc34978e
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/libusb-compat/fix-headers.patch
@@ -0,0 +1,10 @@
+--- libusb-compat-0.1.5.orig/libusb/usb.h
++++ libusb-compat-0.1.5/libusb/usb.h
+@@ -25,6 +25,7 @@
+ #ifndef __USB_H__
+ #define __USB_H__
+ 
++#include <sys/types.h>
+ #include <unistd.h>
+ #include <stdlib.h>
+ #include <limits.h>