Unverified Commit 83b0c9fd authored by Arne Keller's avatar Arne Keller Committed by GitHub
Browse files

readsb: init at 3.14.1641 (#314706)

parents 80122f1d b5248572
Loading
Loading
Loading
Loading
+74 −0
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  fetchFromGitHub,
  pkg-config,
  ncurses,
  rtl-sdr,
  zlib,
  zstd,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "readsb";
  version = "3.14.1641";

  src = fetchFromGitHub {
    owner = "wiedehopf";
    repo = "readsb";
    rev = "refs/tags/v${finalAttrs.version}";
    hash = "sha256-viz/oADxdduan6W0FsetEqifR6fcyeoEZvEnoO/K5/g=";
  };

  strictDeps = true;

  nativeBuildInputs = [ pkg-config ];

  buildInputs = [
    ncurses
    rtl-sdr
    zlib
    zstd
  ];

  # remove version string magic that utilizes git and current time
  postPatch = ''
    sed --in-place '/^READSB_VERSION :=/d' Makefile
  '';

  enableParallelBuilding = true;
  makeFlags = [
    # set something for version, we removed the original value in postPatch
    "READSB_VERSION=${finalAttrs.version}"
  ] ++ (lib.lists.optional (rtl-sdr != null) "RTLSDR=yes");

  doCheck = true;
  checkTarget = "cprtest";
  # TODO there is a crctests target in Make, it describes how to compile ./crctests, but doesn't run
  # it. Compilation also fails with:
  #
  # ld: /build/cc9NI2Fd.o: in function `malloc_or_exit':
  # > /build/source/readsb.h:407:(.text+0xbad): undefined reference to `setExit'
  #
  # Comment this test in once this has been fixed upstream.
  # postCheck = ''
  #   make crctests && ./crctests
  # '';

  installPhase = ''
    runHook preInstall

    mkdir --parent -- $out/bin
    mv readsb viewadsb $out/bin

    runHook postInstall
  '';

  meta = {
    description = "ADS-B decoder swiss knife";
    homepage = "https://github.com/wiedehopf/readsb";
    license = with lib.licenses; [ gpl3Plus ];
    maintainers = with lib.maintainers; [ wucke13 ];
    platforms = lib.platforms.linux; # uses epoll, hence its linux only
  };
})