1{ lib
2, stdenv
3, fetchurl
4, libusb-compat-0_1
5, Security
6, IOKit
7, libobjc
8}:
9
10stdenv.mkDerivation rec {
11 pname = "libftdi";
12 version = "0.20";
13
14 src = fetchurl {
15 url = "https://www.intra2net.com/en/developer/libftdi/download/${pname}-${version}.tar.gz";
16 sha256 = "13l39f6k6gff30hsgh0wa2z422g9pyl91rh8a8zz6f34k2sxaxii";
17 };
18
19 buildInputs = [ libusb-compat-0_1 ] ++ lib.optionals stdenv.isDarwin [ libobjc Security IOKit ];
20
21 propagatedBuildInputs = [ libusb-compat-0_1 ];
22
23 # Hack to avoid TMPDIR in RPATHs.
24 preFixup = ''rm -rf "$(pwd)" '';
25 configureFlags = lib.optional (!stdenv.isDarwin) "--with-async-mode";
26
27 # allow async mode. from ubuntu. see:
28 # https://bazaar.launchpad.net/~ubuntu-branches/ubuntu/trusty/libftdi/trusty/view/head:/debian/patches/04_async_mode.diff
29 patchPhase = ''
30 substituteInPlace ./src/ftdi.c \
31 --replace "ifdef USB_CLASS_PTP" "if 0"
32 '';
33
34 meta = {
35 description = "A library to talk to FTDI chips using libusb";
36 homepage = "https://www.intra2net.com/en/developer/libftdi/";
37 license = lib.licenses.lgpl21;
38 platforms = lib.platforms.all;
39 };
40}