2020-07-18 16:06:22 +00:00
|
|
|
{ stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
|
|
|
, flex
|
|
|
|
, bison
|
|
|
|
, libxml2
|
|
|
|
, python
|
|
|
|
, libusb1
|
|
|
|
, runtimeShell
|
2020-09-25 04:45:31 +00:00
|
|
|
, lib
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "libiio";
|
2020-07-18 16:06:22 +00:00
|
|
|
version = "0.21";
|
|
|
|
|
|
|
|
outputs = [ "out" "lib" "dev" "python" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2020-07-18 16:06:22 +00:00
|
|
|
owner = "analogdevicesinc";
|
|
|
|
repo = "libiio";
|
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = "0psw67mzysdb8fkh8xpcwicm7z94k8plkcc8ymxyvl6inshq0mc7";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-06-01 10:57:12 +00:00
|
|
|
# Revert after https://github.com/NixOS/nixpkgs/issues/125008 is
|
|
|
|
# fixed properly
|
|
|
|
patches = [ ./cmake-fix-libxml2-find-package.patch ];
|
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
flex
|
|
|
|
bison
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
python
|
|
|
|
libxml2
|
|
|
|
libusb1
|
2020-09-25 04:45:31 +00:00
|
|
|
] ++ lib.optional python.isPy3k python.pkgs.setuptools;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
cmakeFlags = [
|
|
|
|
"-DUDEV_RULES_INSTALL_DIR=${placeholder "out"}/lib/udev/rules.d"
|
|
|
|
"-DPYTHON_BINDINGS=on"
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postPatch = ''
|
2020-07-18 16:06:22 +00:00
|
|
|
# Hardcode path to the shared library into the bindings.
|
|
|
|
sed "s#@libiio@#$lib/lib/libiio${stdenv.hostPlatform.extensions.sharedLibrary}#g" ${./hardcode-library-path.patch} | patch -p1
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
substituteInPlace libiio.rules.cmakein \
|
|
|
|
--replace /bin/sh ${runtimeShell}
|
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
2020-07-18 16:06:22 +00:00
|
|
|
# Move Python bindings into a separate output.
|
|
|
|
moveToOutput ${python.sitePackages} "$python"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "API for interfacing with the Linux Industrial I/O Subsystem";
|
2020-07-18 16:06:22 +00:00
|
|
|
homepage = "https://github.com/analogdevicesinc/libiio";
|
|
|
|
license = licenses.lgpl21Plus;
|
|
|
|
platforms = platforms.linux;
|
2020-04-24 23:36:52 +00:00
|
|
|
maintainers = with maintainers; [ thoughtpolice ];
|
|
|
|
};
|
|
|
|
}
|