Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at flake-libs 100 lines 2.4 kB view raw
1{ 2 stdenv, 3 fetchFromGitHub, 4 cmake, 5 flex, 6 bison, 7 libxml2, 8 pythonSupport ? stdenv.hostPlatform.hasSharedLibraries, 9 python3, 10 libusb1, 11 avahiSupport ? true, 12 avahi, 13 libaio, 14 runtimeShell, 15 lib, 16 pkg-config, 17}: 18 19stdenv.mkDerivation rec { 20 pname = "libiio"; 21 version = "0.24"; 22 23 outputs = [ 24 "out" 25 "lib" 26 "dev" 27 ] ++ lib.optional pythonSupport "python"; 28 29 src = fetchFromGitHub { 30 owner = "analogdevicesinc"; 31 repo = "libiio"; 32 rev = "v${version}"; 33 sha256 = "sha256-c5HsxCdp1cv5BGTQ/8dc8J893zk9ntbfAudLpqoQ1ow="; 34 }; 35 36 # Revert after https://github.com/NixOS/nixpkgs/issues/125008 is 37 # fixed properly 38 patches = [ ./cmake-fix-libxml2-find-package.patch ]; 39 40 nativeBuildInputs = 41 [ 42 cmake 43 flex 44 bison 45 pkg-config 46 ] 47 ++ lib.optionals pythonSupport ( 48 [ 49 python3 50 ] 51 ++ lib.optional python3.isPy3k python3.pkgs.setuptools 52 ); 53 54 buildInputs = 55 [ 56 libxml2 57 libusb1 58 ] 59 ++ lib.optional avahiSupport avahi 60 ++ lib.optional stdenv.hostPlatform.isLinux libaio; 61 62 cmakeFlags = 63 [ 64 "-DUDEV_RULES_INSTALL_DIR=${placeholder "out"}/lib/udev/rules.d" 65 # osx framework is disabled, 66 # the linux-like directory structure is used for proper output splitting 67 "-DOSX_PACKAGE=off" 68 "-DOSX_FRAMEWORK=off" 69 ] 70 ++ lib.optionals pythonSupport [ 71 "-DPython_EXECUTABLE=${python3.pythonOnBuildForHost.interpreter}" 72 "-DPYTHON_BINDINGS=on" 73 ] 74 ++ lib.optionals (!avahiSupport) [ 75 "-DHAVE_DNS_SD=OFF" 76 ]; 77 78 postPatch = 79 '' 80 substituteInPlace libiio.rules.cmakein \ 81 --replace /bin/sh ${runtimeShell} 82 '' 83 + lib.optionalString pythonSupport '' 84 # Hardcode path to the shared library into the bindings. 85 sed "s#@libiio@#$lib/lib/libiio${stdenv.hostPlatform.extensions.sharedLibrary}#g" ${./hardcode-library-path.patch} | patch -p1 86 ''; 87 88 postInstall = lib.optionalString pythonSupport '' 89 # Move Python bindings into a separate output. 90 moveToOutput ${python3.sitePackages} "$python" 91 ''; 92 93 meta = with lib; { 94 description = "API for interfacing with the Linux Industrial I/O Subsystem"; 95 homepage = "https://github.com/analogdevicesinc/libiio"; 96 license = licenses.lgpl21Plus; 97 platforms = platforms.linux ++ platforms.darwin; 98 maintainers = with maintainers; [ thoughtpolice ]; 99 }; 100}