summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/hi/hidapi/package.nix
blob: ae773ba85eacacb45c87537bc4f83546159b8337 (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
54
55
56
{
  lib,
  stdenv,
  fetchFromGitHub,
  cmake,
  pkg-config,
  libusb1,
  udev,
  testers,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "hidapi";
  version = "0.15.0";

  src = fetchFromGitHub {
    owner = "libusb";
    repo = "hidapi";
    rev = "hidapi-${finalAttrs.version}";
    sha256 = "sha256-o6IZRG42kTa7EQib9eaV1HGyjaGgeCabk+8fyQTm/0s=";
  };

  nativeBuildInputs = [
    cmake
    pkg-config
  ];

  buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
    libusb1
    udev
  ];

  enableParallelBuilding = true;

  passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;

  meta = {
    description = "Library for communicating with USB and Bluetooth HID devices";
    homepage = "https://github.com/libusb/hidapi";
    maintainers = with lib.maintainers; [ prusnak ];
    # You can choose between GPLv3, BSD or HIDAPI license (even more liberal)
    license = with lib.licenses; [
      bsd3 # or
      gpl3Only
    ];
    pkgConfigModules =
      lib.optionals stdenv.hostPlatform.isDarwin [
        "hidapi"
      ]
      ++ lib.optionals stdenv.hostPlatform.isLinux [
        "hidapi-hidraw"
        "hidapi-libusb"
      ];
    platforms = lib.platforms.unix ++ lib.platforms.windows;
  };
})