{ qmake
, wrapQtAppsHook
, fetchFromGitHub
, pkg-config
, stdenv
, lib
, pkgs
# Package dependencies
, qttools
, atools
}:

stdenv.mkDerivation rec {
	pname = "littlefgconnect";
	version = "0.1";

	src = fetchFromGitHub {
		owner = "slawekmikula";
		repo = pname;
		rev = "f082b2fc7e2dbe61384dd1e362859f5309500859";
		sha256 = "sha256-W7K3aAsmITOmX73z3nDzVPUWzgYf+FwHVpgz9Pwo13E=";
	};

	patches = [ ./fix-var-name.patch ];

	ATOOLS_LIB_PATH = atools;
	ATOOLS_INC_PATH = "${atools}/include/src";

	nativeBuildInputs = [
		wrapQtAppsHook
		qmake
		pkg-config
		qttools
	];
	buildInputs = [
		atools
	];

	buildPhase = ''
		runHook preBuild
		mkdir -p build
		cd build
		qmake ../littlefgconnect.pro CONFIG+="release" QMAKE_CXXFLAGS+=' -Wno-deprecated-copy -Wno-deprecated -Wno-deprecated-declarations'
		make -j $(nproc)
		runHook postBuild
	'';

	installPhase = ''
		runHook preInstall
		mkdir -p $out/bin
		mv littlefgconnect $out/bin/
		runHook postInstall
	'';

	meta = with lib; {
		homepage = "https://github.com/slawekmikula/littlefgconnect";
		description = "Connector between Littlenavmap and Flightgear";
		license = licenses.gpl3;
		platforms = platforms.all;
		maintainers = with maintainers; [];
	};
}