aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/pkgs/development/libraries/libiio/default.nix
blob: c4136428035cf77f1a445b743b79043ef5419bc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{ stdenv
, fetchFromGitHub
, cmake
, flex
, bison
, libxml2
, python
, libusb1
, runtimeShell
}:

stdenv.mkDerivation rec {
  pname = "libiio";
  version = "0.21";

  outputs = [ "out" "lib" "dev" "python" ];

  src = fetchFromGitHub {
    owner = "analogdevicesinc";
    repo = "libiio";
    rev = "v${version}";
    sha256 = "0psw67mzysdb8fkh8xpcwicm7z94k8plkcc8ymxyvl6inshq0mc7";
  };

  nativeBuildInputs = [
    cmake
    flex
    bison
  ];

  buildInputs = [
    python
    libxml2
    libusb1
  ];

  cmakeFlags = [
    "-DUDEV_RULES_INSTALL_DIR=${placeholder "out"}/lib/udev/rules.d"
    "-DPYTHON_BINDINGS=on"
  ];

  postPatch = ''
    # 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

    substituteInPlace libiio.rules.cmakein \
      --replace /bin/sh ${runtimeShell}
  '';

  postInstall = ''
    # Move Python bindings into a separate output.
    moveToOutput ${python.sitePackages} "$python"
  '';

  meta = with stdenv.lib; {
    description = "API for interfacing with the Linux Industrial I/O Subsystem";
    homepage = "https://github.com/analogdevicesinc/libiio";
    license = licenses.lgpl21Plus;
    platforms = platforms.linux;
    maintainers = with maintainers; [ thoughtpolice ];
  };
}