nixos-piaware/packages/piaware.nix
2023-12-13 23:32:42 -06:00

92 lines
2.6 KiB
Nix

{ pkgs, dump1090-fa, dump978-fa, tcllauncher, mutability-mlat-client, ... }:
let
pname = "piaware";
version = "8.2";
in
pkgs.stdenv.mkDerivation {
inherit pname version;
src = pkgs.fetchFromGitHub {
owner = "flightaware";
repo = "piaware";
rev = "v${version}";
sha256 = "sha256-La0J+6Y0cWr6fTr0ppzYV6Vq00GisyDxmSyGzR7nfpg=";
};
nativeBuildInputs = [
pkgs.makeWrapper
pkgs.which
];
propagatedBuildInputs = [
pkgs.coreutils
pkgs.iproute2
pkgs.openssl
pkgs.tcl
pkgs.tcltls
pkgs.tclx
tcllauncher
];
dontPatch = true;
dontConfigure = true;
buildPhase = ''
runHook preBuild
substituteInPlace programs/piaware/login.tcl \
--replace /bin/uname ${pkgs.coreutils}/bin/uname
substituteInPlace programs/piaware/helpers.tcl \
--replace /bin/uname ${pkgs.coreutils}/bin/uname
substituteInPlace programs/piaware/update.tcl \
--replace /sbin/reboot ${pkgs.systemd}/bin/reboot \
--replace /sbin/halt ${pkgs.systemd}/bin/halt
substituteInPlace programs/piaware/faup1090.tcl \
--replace /usr/lib/piaware/helpers/faup1090 ${dump1090-fa}/bin/faup1090
substituteInPlace programs/piaware/faup978.tcl \
--replace /usr/lib/piaware/helpers/faup978 ${dump978-fa}/bin/faup978
substituteInPlace programs/piaware/mlat.tcl \
--replace /usr/lib/piaware/helpers/fa-mutability-mlat-client ${mutability-mlat-client}/bin/fa-mutability-mlat-client
substituteInPlace package/fa_sysinfo.tcl \
--replace /sbin/ip ${pkgs.iproute2}/bin/ip \
--replace /bin/df ${pkgs.coreutils}/bin/df
substituteInPlace package/piaware.tcl \
--replace "list netstat --program" "list ${pkgs.nettools}/bin/netstat --program"
substituteInPlace package/helpers/restart-network \
--replace /bin/systemctl ${pkgs.systemd}/bin/systemctl
substituteInPlace package/helpers/restart-receiver \
--replace /bin/systemctl ${pkgs.systemd}/bin/systemctl
runHook postBuild
'';
installFlags = [
''DESTDIR=''${out}''
"PREFIX=/"
"INSTALL_SUDOERS=1"
];
postFixup =
let
tcllibpath = "$out/lib ${tcllauncher}/lib ${pkgs.tcl}/lib ${pkgs.tclx}/lib ${pkgs.tcltls}/lib ${pkgs.tcllib}/lib";
in
''
for f in piaware piaware-config piaware-status pirehose
do
ln -sf ${tcllauncher}/bin/tcllauncher $out/bin/$f
wrapProgram $out/bin/$f \
--set TCLLIBPATH "${tcllibpath}"
done
'';
meta = with pkgs.lib; {
homepage = "https://github.com/flightaware/piaware";
description = "";
longDescription = '' '';
license = licenses.gpl2Plus;
};
}