about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-3rdparty.nix
blob: fdbdb4db24bf72640f60d7d4a5e47d273d819482 (plain) (blame)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
{ stdenv
, lib
, bash
, cmake
, coreutils
, cfitsio
, libusb1
, zlib
, boost
, libnova
, curl
, libjpeg
, gsl
, fftw
, indilib
, libgphoto2
, libraw
, libftdi1
, libdc1394
, gpsd
, ffmpeg
, limesuite
, version
, src
, withFirmware ? false
, firmware ? null
}:

let
  libusb-with-fxload = libusb1.override { withExamples = true;};
in

stdenv.mkDerivation rec {
  pname = "indi-3rdparty";

  inherit version src;

  nativeBuildInputs = [ cmake ];

  buildInputs = [
    indilib libnova curl cfitsio libusb1 zlib boost gsl gpsd
    libjpeg libgphoto2 libraw libftdi1 libdc1394 ffmpeg fftw
    limesuite
  ] ++ lib.optionals withFirmware [
    firmware
  ];

  postPatch = ''
    for f in $(find . -name "CMakeLists.txt"); do
      substituteInPlace $f \
        --replace "/lib/udev/rules.d" "lib/udev/rules.d" \
        --replace "/etc/udev/rules.d" "lib/udev/rules.d" \
        --replace "/lib/firmware" "lib/firmware"
    done

    substituteInPlace libpktriggercord/CMakeLists.txt \
      --replace "set (PK_DATADIR /usr/share/pktriggercord)" "set (PK_DATADIR $out/share/pkgtriggercord)"

    sed '1i#include <ctime>' -i indi-duino/libfirmata/src/firmata.cpp # gcc12
  '';

  cmakeFlags = [
    "-DINDI_DATA_DIR=share/indi"
    "-DCMAKE_INSTALL_LIBDIR=lib"
    "-DUDEVRULES_INSTALL_DIR=lib/udev/rules.d"
    "-DRULES_INSTALL_DIR=lib/udev/rules.d"
  ] ++ lib.optionals (!withFirmware) [
    "-DWITH_ATIK=off"
    "-DWITH_APOGEE=off"
    "-DWITH_DSI=off"
    "-DWITH_QHY=off"
    "-DWITH_ARMADILLO=off"
    "-DWITH_FISHCAMP=off"
    "-DWITH_SBIG=off"
  ];

  postFixup = lib.optionalString stdenv.isLinux ''
    for f in $out/lib/udev/rules.d/*.rules
    do
      substituteInPlace $f --replace "/sbin/fxload" "${libusb-with-fxload}/sbin/fxload" \
                           --replace "/lib/firmware/" "$out/lib/firmware/" \
                           --replace "/bin/sleep" "${coreutils}/bin/sleep" \
                           --replace "/bin/cat" "${coreutils}/bin/cat" \
                           --replace "/bin/echo" "${coreutils}/bin/echo" \
                           --replace "/bin/sh" "${bash}/bin/sh"
    done
  '';


  meta = with lib; {
    homepage = "https://www.indilib.org/";
    description = "Third party drivers for the INDI astronomical software suite";
    changelog = "https://github.com/indilib/indi-3rdparty/releases/tag/v${version}";
    license = licenses.lgpl2Plus;
    maintainers = with maintainers; [ hjones2199 sheepforce ];
    platforms = platforms.linux;
  };
}