1{ lib
2, stdenv
3, fetchFromGitHub
4, substituteAll
5, meson
6, ninja
7, pkg-config
8, gobject-introspection
9, gi-docgen
10, python3
11, glib
12, libusb1
13, json-glib
14, vala
15, hwdata
16, umockdev
17}:
18
19let
20 pythonEnv = python3.pythonOnBuildForHost.withPackages (ps: with ps; [
21 setuptools
22 ]);
23in
24stdenv.mkDerivation rec {
25 pname = "gusb";
26 version = "0.4.8";
27
28 outputs = [ "bin" "out" "dev" "devdoc" ];
29
30 src = fetchFromGitHub {
31 owner = "hughsie";
32 repo = "libgusb";
33 rev = "refs/tags/${version}";
34 hash = "sha256-xhWx45uOh8Yokd3/32CQ6tsdkgGaYUOvaylrq/jmoP0=";
35 };
36
37 patches = [
38 (substituteAll {
39 src = ./fix-python-path.patch;
40 python = "${pythonEnv}/bin/python3";
41 })
42 ];
43
44 strictDeps = true;
45
46 depsBuildBuild = [
47 pkg-config
48 ];
49
50 nativeBuildInputs = [
51 meson
52 ninja
53 pkg-config
54 gobject-introspection
55 gi-docgen
56 vala
57 ];
58
59 # all required in gusb.pc
60 propagatedBuildInputs = [
61 glib
62 libusb1
63 json-glib
64 ];
65
66 mesonFlags = [
67 (lib.mesonBool "tests" doCheck)
68 (lib.mesonOption "usb_ids" "${hwdata}/share/hwdata/usb.ids")
69 ];
70
71 checkInputs = [
72 umockdev
73 ];
74
75 doCheck = false; # tests try to access USB
76
77 postFixup = ''
78 # Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back.
79 ls -la "$out/share/doc"
80 moveToOutput "share/doc" "$devdoc"
81 '';
82
83 meta = with lib; {
84 description = "GLib libusb wrapper";
85 homepage = "https://github.com/hughsie/libgusb";
86 license = licenses.lgpl21;
87 maintainers = [ maintainers.marcweber ];
88 platforms = platforms.unix;
89 };
90}