libftdi1: 1.4 -> 1.5, refactor

OPNA2608 06c6ec1c bef62e8c

+51 -25
+51 -25
pkgs/development/libraries/libftdi/1.x.nix
··· 1 - { lib, stdenv, fetchurl, cmake, pkg-config, libusb1, libconfuse 2 - , cppSupport ? true, boost ? null 3 - , pythonSupport ? true, python3 ? null, swig ? null 4 - , docSupport ? true, doxygen ? null 1 + { lib 2 + , stdenv 3 + , fetchgit 4 + , cmake 5 + , pkg-config 6 + , libusb1 7 + , libconfuse 8 + , cppSupport ? true 9 + , boost 10 + , pythonSupport ? true 11 + , python3 12 + , swig 13 + , docSupport ? true 14 + , doxygen 15 + , graphviz 5 16 }: 6 17 7 - assert cppSupport -> boost != null; 8 - assert pythonSupport -> python3 != null && swig != null; 9 - assert docSupport -> doxygen != null; 10 - 18 + let 19 + inherit (lib) optionals optionalString; 20 + onOff = a: if a then "ON" else "OFF"; 21 + in 11 22 stdenv.mkDerivation rec { 12 - name = "libftdi1-1.4"; 23 + pname = "libftdi"; 24 + version = "1.5"; 13 25 14 - src = fetchurl { 15 - url = "https://www.intra2net.com/en/developer/libftdi/download/${name}.tar.bz2"; 16 - sha256 = "0x0vncf6i92slgrn0h7ghkskqbglbs534220qa84d0qg114zndpc"; 26 + src = fetchgit { 27 + url = "git://developer.intra2net.com/libftdi"; 28 + rev = "v${version}"; 29 + sha256 = "0vipg3y0kbbzjhxky6hfyxy42mpqhvwn1r010zr5givcfp8ghq26"; 17 30 }; 18 31 19 - nativeBuildInputs = [ cmake pkg-config ]; 20 - buildInputs = with lib; [ libconfuse ] 32 + nativeBuildInputs = [ cmake pkg-config ] 33 + ++ optionals docSupport [ doxygen graphviz ] 34 + ++ optionals pythonSupport [ swig ]; 35 + 36 + buildInputs = [ libconfuse ] 21 37 ++ optionals cppSupport [ boost ] 22 - ++ optionals pythonSupport [ python3 swig ] 23 - ++ optionals docSupport [ doxygen ]; 38 + ++ optionals pythonSupport [ python3 ]; 24 39 25 - preBuild = lib.optionalString docSupport '' 26 - make doc_i 27 - ''; 40 + cmakeFlags = [ 41 + "-DFTDIPP=${onOff cppSupport}" 42 + "-DBUILD_TESTS=${onOff cppSupport}" 43 + "-DLINK_PYTHON_LIBRARY=${onOff pythonSupport}" 44 + "-DPYTHON_BINDINGS=${onOff pythonSupport}" 45 + "-DDOCUMENTATION=${onOff docSupport}" 46 + ]; 28 47 29 48 propagatedBuildInputs = [ libusb1 ]; 30 49 31 50 postInstall = '' 32 51 mkdir -p "$out/etc/udev/rules.d/" 33 52 cp ../packages/99-libftdi.rules "$out/etc/udev/rules.d/" 53 + '' + optionalString docSupport '' 34 54 cp -r doc/man "$out/share/" 35 - '' + lib.optionalString docSupport '' 36 - mkdir -p "$out/share/libftdi/doc/" 37 - cp -r doc/html "$out/share/libftdi/doc/" 55 + cp -r doc/html "$out/share/doc/libftdi1/" 56 + ''; 57 + 58 + postFixup = optionalString cppSupport '' 59 + # This gets misassigned to the C++ version's path for some reason 60 + for fileToFix in $out/{bin/libftdi1-config,lib/pkgconfig/libftdi1.pc}; do 61 + substituteInPlace $fileToFix \ 62 + --replace "$out/include/libftdipp1" "$out/include/libftdi1" 63 + done 38 64 ''; 39 65 40 66 meta = with lib; { 41 67 description = "A library to talk to FTDI chips using libusb"; 42 68 homepage = "https://www.intra2net.com/en/developer/libftdi/"; 43 - license = with licenses; [ lgpl2 gpl2 ]; 44 - platforms = with platforms; linux ++ darwin; 45 - maintainers = [ maintainers.bjornfor ]; 69 + license = with licenses; [ lgpl2Only gpl2Only ]; 70 + platforms = platforms.all; 71 + maintainers = with maintainers; [ bjornfor ]; 46 72 }; 47 73 }