1{
2 stdenv,
3 autoconf,
4 automake,
5 fetchFromGitHub,
6 fetchpatch,
7 gettext,
8 lib,
9 libiconv,
10 libtool,
11 libusb1,
12 pkg-config,
13 buildPackages,
14}:
15
16stdenv.mkDerivation rec {
17 pname = "libmtp";
18 version = "1.1.22";
19
20 src = fetchFromGitHub {
21 owner = "libmtp";
22 repo = "libmtp";
23 rev = "libmtp-${builtins.replaceStrings [ "." ] [ "-" ] version}";
24 sha256 = "sha256-hIH6W8qQ6DB4ST7SlFz6CCnLsEGOWgmUb9HoHMNA3wY=";
25 };
26
27 patches = [
28 # gettext-0.25 support
29 (fetchpatch {
30 name = "gettext-0.25.patch";
31 url = "https://github.com/libmtp/libmtp/commit/5e53ee68e61cc6547476b942b6aa9776da5d4eda.patch";
32 hash = "sha256-eXDNDHg8K+ZiO9n4RqQPJrh4V9GNiK/ZxZOA/oIX83M=";
33 })
34 (fetchpatch {
35 name = "gettext-0.25-p2.patch";
36 url = "https://github.com/libmtp/libmtp/commit/122eb9d78b370955b9c4d7618b12a2429f01b81a.patch";
37 hash = "sha256-Skqr6REBl/Egf9tS5q8k5qmEhFY+rG2fymbiu9e4Mho=";
38 })
39 ];
40
41 outputs = [
42 "bin"
43 "dev"
44 "out"
45 ];
46
47 nativeBuildInputs = [
48 autoconf
49 automake
50 gettext
51 libtool
52 pkg-config
53 ];
54
55 buildInputs = [ libiconv ];
56
57 propagatedBuildInputs = [ libusb1 ];
58
59 preConfigure = ''
60 autopoint -f
61 NOCONFIGURE=1 ./autogen.sh
62 '';
63
64 configureFlags = [ "--with-udev=${placeholder "out"}/lib/udev" ];
65
66 configurePlatforms = [
67 "build"
68 "host"
69 ];
70
71 makeFlags =
72 lib.optionals (stdenv.hostPlatform.isLinux && !stdenv.buildPlatform.canExecute stdenv.hostPlatform)
73 [
74 "MTP_HOTPLUG=${buildPackages.libmtp}/bin/mtp-hotplug"
75 ];
76
77 enableParallelBuilding = true;
78
79 doInstallCheck = true;
80
81 meta = with lib; {
82 homepage = "https://github.com/libmtp/libmtp";
83 description = "Implementation of Microsoft's Media Transfer Protocol";
84 longDescription = ''
85 libmtp is an implementation of Microsoft's Media Transfer Protocol (MTP)
86 in the form of a library suitable primarily for POSIX compliant operating
87 systems. We implement MTP Basic, the stuff proposed for standardization.
88 '';
89 platforms = platforms.unix;
90 license = licenses.lgpl21;
91 maintainers = with maintainers; [ lovesegfault ];
92 };
93}