1{ stdenv
2, autoconf
3, automake
4, fetchFromGitHub
5, fetchpatch
6, gettext
7, lib
8, libiconv
9, libtool
10, libusb1
11, pkg-config
12, buildPackages
13}:
14
15stdenv.mkDerivation rec {
16 pname = "libmtp";
17 version = "1.1.21";
18
19 src = fetchFromGitHub {
20 owner = "libmtp";
21 repo = "libmtp";
22 rev = "libmtp-${builtins.replaceStrings [ "." ] [ "-" ] version}";
23 sha256 = "sha256-m9QFVD8udQ3SdGwn276BnIKqGeATA5QuokOK29Ykc1k=";
24 };
25
26 patches = [
27 # Backport cross fix.
28 (fetchpatch {
29 url = "https://github.com/libmtp/libmtp/commit/467fa26e6b14c0884b15cf6d191de97e5513fe05.patch";
30 sha256 = "2DrRrdcguJ9su4LxtT6YOjer8gUTxIoHVpk+6M9P4cg=";
31 })
32 ];
33
34 outputs = [ "bin" "dev" "out" ];
35
36 nativeBuildInputs = [
37 autoconf
38 automake
39 gettext
40 libtool
41 pkg-config
42 ];
43
44 buildInputs = [ libiconv ];
45
46 propagatedBuildInputs = [ libusb1 ];
47
48 preConfigure = "NOCONFIGURE=1 ./autogen.sh";
49
50 configureFlags = [ "--with-udev=${placeholder "out"}/lib/udev" ];
51
52 configurePlatforms = [ "build" "host" ];
53
54 makeFlags = lib.optionals (stdenv.isLinux && !stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
55 "MTP_HOTPLUG=${buildPackages.libmtp}/bin/mtp-hotplug"
56 ];
57
58 enableParallelBuilding = true;
59
60 meta = with lib; {
61 homepage = "https://github.com/libmtp/libmtp";
62 description = "An implementation of Microsoft's Media Transfer Protocol";
63 longDescription = ''
64 libmtp is an implementation of Microsoft's Media Transfer Protocol (MTP)
65 in the form of a library suitable primarily for POSIX compliant operating
66 systems. We implement MTP Basic, the stuff proposed for standardization.
67 '';
68 platforms = platforms.unix;
69 license = licenses.lgpl21;
70 maintainers = with maintainers; [ lovesegfault ];
71 };
72}