From 973a32c51e7b3e66f19ecf0a57d71fdb12c95c1a Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Mon, 9 Jan 2023 02:08:57 +0000 Subject: [PATCH] fr24feed/mlat-client/piaware/tar1090: init --- nix/pkgs/default.nix | 9 +++- nix/pkgs/fr24feed/default.nix | 43 +++++++++++++++++++ nix/pkgs/mlat-client/default.nix | 15 +++++++ nix/pkgs/piaware/faup1090.nix | 17 ++++++++ nix/pkgs/piaware/piaware.nix | 71 ++++++++++++++++++++++++++++++++ nix/pkgs/piaware/tcllauncher.nix | 45 ++++++++++++++++++++ nix/pkgs/tar1090/default.nix | 56 +++++++++++++++++++++++++ 7 files changed, 255 insertions(+), 1 deletion(-) create mode 100644 nix/pkgs/fr24feed/default.nix create mode 100644 nix/pkgs/mlat-client/default.nix create mode 100644 nix/pkgs/piaware/faup1090.nix create mode 100644 nix/pkgs/piaware/piaware.nix create mode 100644 nix/pkgs/piaware/tcllauncher.nix create mode 100644 nix/pkgs/tar1090/default.nix diff --git a/nix/pkgs/default.nix b/nix/pkgs/default.nix index 20a41d0c77..b2d2824bb3 100644 --- a/nix/pkgs/default.nix +++ b/nix/pkgs/default.nix @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 -{ depot, pkgs, ... }@args: { +{ depot, pkgs, ... }@args: rec { bazel-run = import ./bazel-run.nix args; crane = import ./crane.nix args; javaws-env = import ./javaws-env.nix args; @@ -73,5 +73,12 @@ authentik = import ./authentik args; flipperzero-firmware = import ./flipperzero-firmware args; jj = import ./jj.nix args; + readsb = pkgs.callPackage ./readsb { }; + mlat-client = pkgs.python3.pkgs.callPackage ./mlat-client { }; + tcllauncher = pkgs.callPackage ./piaware/tcllauncher.nix { }; + piaware = pkgs.callPackage ./piaware/piaware.nix { inherit tcllauncher faup1090 mlat-client; }; + faup1090 = pkgs.callPackage ./piaware/faup1090.nix { }; + fr24feed = pkgs.callPackage ./fr24feed { }; + } // (import ./heptapod-runner args) diff --git a/nix/pkgs/fr24feed/default.nix b/nix/pkgs/fr24feed/default.nix new file mode 100644 index 0000000000..9909c8d73c --- /dev/null +++ b/nix/pkgs/fr24feed/default.nix @@ -0,0 +1,43 @@ +{ stdenv +, lib +, fetchurl +, buildFHSUserEnv +, bash +, writeText +}: + +let + fr24feed = stdenv.mkDerivation rec { + pname = "fr24feed-unwrapped"; + version = "1.0.25-3"; + + src = fetchurl { + url = "https://repo-feed.flightradar24.com/linux_x86_64_binaries/fr24feed_${version}_amd64.tgz"; + sha256 = "sha256:0gvb1p2lhgcrgpid3nqid92sbpg8561yfjlnbmi07bhs3vcilmbq"; + }; + + installPhase = '' + runHook preInstall + install -Dm 0755 fr24feed $out/bin/fr24feed + runHook postInstall + ''; + }; +in +buildFHSUserEnv { + name = "fr24feed"; + targetPkgs = pkgs: with pkgs; [ + bash + ]; + + extraBuildCommands = '' + chmod +w etc + ln -s /host/etc/fr24feed.ini etc/fr24feed.ini + ''; + + runScript = "${bash}/bin/bash ${ + writeText "fr24feed" + '' + exec ${fr24feed}/bin/fr24feed "$@" + '' + }"; +} diff --git a/nix/pkgs/mlat-client/default.nix b/nix/pkgs/mlat-client/default.nix new file mode 100644 index 0000000000..343ec8c9fa --- /dev/null +++ b/nix/pkgs/mlat-client/default.nix @@ -0,0 +1,15 @@ +{ buildPythonApplication +, fetchFromGitHub +}: + +buildPythonApplication rec { + pname = "mlat-client"; + version = "0.4.2"; + + src = fetchFromGitHub { + owner = "adsbxchange"; + repo = "mlat-client"; + rev = "v${version}"; + sha256 = "sha256:0v2f5ikl7salvvqxwq1n8v4z7p4m2yg6kxd5hpyd8pl1i6jwpzsp"; + }; +} diff --git a/nix/pkgs/piaware/faup1090.nix b/nix/pkgs/piaware/faup1090.nix new file mode 100644 index 0000000000..ef47dad64f --- /dev/null +++ b/nix/pkgs/piaware/faup1090.nix @@ -0,0 +1,17 @@ +{ dump1090 +}: + +dump1090.overrideAttrs (oldAttrs: { + pname = "faup1090"; + + buildFlags = [ "faup1090" ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/bin + cp -v faup1090 $out/bin + + runHook postInstall + ''; +}) diff --git a/nix/pkgs/piaware/piaware.nix b/nix/pkgs/piaware/piaware.nix new file mode 100644 index 0000000000..953733a3a3 --- /dev/null +++ b/nix/pkgs/piaware/piaware.nix @@ -0,0 +1,71 @@ +{ lib +, fetchFromGitHub +, stdenv +, coreutils +, iproute2 +, openssl +, tcllauncher +, tcl +, tcllib +, tcltls +, tclx +, faup1090 +, mlat-client +, which +, makeWrapper +}: + +stdenv.mkDerivation rec { + pname = "piaware"; + version = "8.2"; + + src = fetchFromGitHub { + owner = "flightaware"; + repo = "piaware"; + rev = "v${version}"; + sha256 = "sha256:163ywwgcv1ick7qj1cx2879nm9apv2fadx1sgpx6lw9llvxhkb9d"; + }; + + postPatch = '' + substituteInPlace package/fa_sysinfo.tcl \ + --replace "/bin/df" "${coreutils}/bin/df" \ + --replace "/sbin/ip" "${iproute2}/bin/ip" \ + --replace "|ip" "|${iproute2}/bin/ip" + + substituteInPlace programs/piaware/login.tcl \ + --replace "/bin/uname" "${coreutils}/bin/uname" + + substituteInPlace programs/piaware/helpers.tcl \ + --replace "/bin/uname" "${coreutils}/bin/uname" + + substituteInPlace programs/piaware/faup1090.tcl \ + --replace "/usr/lib/piaware/helpers/faup1090" "${faup1090}/bin/faup1090" + + substituteInPlace programs/piaware/mlat.tcl \ + --replace "/usr/lib/piaware/helpers/fa-mlat-client" "${mlat-client}/bin/fa-mlat-client" + ''; + + buildInputs = [ + tcllauncher + ]; + nativeBuildInputs = [ + openssl + which + tcl + makeWrapper + ]; + + makeFlags = "PREFIX= DESTDIR=${placeholder "out"}"; + enableParallelBuilding = true; + + postInstall = '' + wrapProgram $out/bin/piaware \ + --suffix TCLLIBPATH ' ' "${tcltls}/lib ${tcllib}/lib ${tcllauncher}/lib ${tclx}/lib ${placeholder "out"}/lib" + wrapProgram $out/bin/piaware-config \ + --suffix TCLLIBPATH ' ' "${tcltls}/lib ${tcllib}/lib ${tcllauncher}/lib ${tclx}/lib ${placeholder "out"}/lib" + wrapProgram $out/bin/piaware-status \ + --suffix TCLLIBPATH ' ' "${tcltls}/lib ${tcllib}/lib ${tcllauncher}/lib ${tclx}/lib ${placeholder "out"}/lib" + wrapProgram $out/bin/pirehose \ + --suffix TCLLIBPATH ' ' "${tcltls}/lib ${tcllib}/lib ${tcllauncher}/lib ${tclx}/lib ${placeholder "out"}/lib" + ''; +} diff --git a/nix/pkgs/piaware/tcllauncher.nix b/nix/pkgs/piaware/tcllauncher.nix new file mode 100644 index 0000000000..00f5cd261a --- /dev/null +++ b/nix/pkgs/piaware/tcllauncher.nix @@ -0,0 +1,45 @@ +{ lib +, fetchFromGitHub +, stdenv +, tcl +, tclx +, makeWrapper +, pkg-config +, autoreconfHook +}: + +stdenv.mkDerivation rec { + pname = "tcllauncher"; + version = "1.10"; + + src = fetchFromGitHub { + owner = "flightaware"; + repo = "tcllauncher"; + rev = "v${version}"; + sha256 = "sha256:0zjq6s7ny0a72qmbbigsqp151kb316hvydsl6dl10y6arjhyqnh5"; + }; + + buildInputs = [ + tcl + tclx + ]; + + nativeBuildInputs = [ + autoreconfHook + pkg-config + makeWrapper + ]; + + configureFlags = [ + "--with-tcl=${tcl}/lib" + "--with-tclinclude=${tcl}/include" + "--exec-prefix=${placeholder "out"}" + ]; + makeFlags = [ "DESTDIR=/" ]; + enableParallelBuilding = true; + + #postInstall = '' + # wrapProgram $out/bin/tcllauncher \ + # --suffix TCLLIBPATH ' ' "${tclx}/lib ${placeholder "out"}/lib" + #''; +} diff --git a/nix/pkgs/tar1090/default.nix b/nix/pkgs/tar1090/default.nix new file mode 100644 index 0000000000..df127e76c5 --- /dev/null +++ b/nix/pkgs/tar1090/default.nix @@ -0,0 +1,56 @@ +{ lib +, fetchFromGitHub +, stdenv + +, pkg-config +}: + +let + tar1090 = fetchFromGitHub { + owner = "wiedehopf"; + repo = "tar1090"; + rev = "0678a884f18c4ce78b569a88340db3763ae45ff6"; + sha256 = "sha256:0000000000000000000000000000000000000000000000000000"; + }; + tar1090-db = fetchFromGitHub { + owner = "wiedehopf"; + repo = "tar1090-db"; + rev = "bad4a563c52d71e791d4dbdb392e2257b3df7f17"; + sha256 = "sha256:0000000000000000000000000000000000000000000000000000"; + }; +in +stdenv.mkDerivation rec { + pname = "tar1090"; + version = "unstable-2022-10-06"; + + src = tar1090; + + buildInputs = [ + libusb1 + ncurses + zlib + zstd + + librtlsdr + libbladeRF + libiio + libad9361 + ]; + + nativeBuildInputs = [ + pkg-config + ]; + + makeFlags = "RTLSDR=yes AIRCRAFT_HASH_BITS=15 HISTORY=yes BLADERF=yes PLUTOSDR=yes AGGRESSIVE=yes HAVE_BIASTEE=yes"; + enableParallelBuilding = true; + + installPhase = '' + runHook preInstall + + install -d $out/bin + install -m 0755 readsb $out/bin/readsb + ln -s $out/bin/readsb $out/bin/viewadsb + + runHook postInstall + ''; +}