1{
2 pkgs,
3 mkDerivation,
4 lib,
5 callPackage,
6 fetchzip,
7 fetchFromGitHub,
8 cmake,
9 pkg-config,
10 ninja,
11 copyDesktopItems,
12 qtbase,
13 qttools,
14 opencv4,
15 procps,
16 eigen,
17 libXdmcp,
18 libevdev,
19 makeDesktopItem,
20 fetchurl,
21 fetchpatch,
22 wineWowPackages,
23 onnxruntime,
24}:
25let
26 version = "2023.3.0";
27
28 aruco = callPackage ./aruco.nix { };
29
30 # license.txt inside the zip file is MIT
31 xplaneSdk = fetchzip {
32 url = "https://developer.x-plane.com/wp-content/plugins/code-sample-generation/sdk_zip_files/XPSDK401.zip";
33 hash = "sha256-tUT9yV1949QVr5VebU/7esg7wwWkyak2TSA/kQSrbeo=";
34 };
35in
36mkDerivation {
37 pname = "opentrack";
38 inherit version;
39
40 src = fetchFromGitHub {
41 owner = "opentrack";
42 repo = "opentrack";
43 rev = "opentrack-${version}";
44 hash = "sha256-C0jLS55DcLJh/e5yM8kLG7fhhKvBNllv5HkfCWRIfc4=";
45 };
46
47 patches = [
48 # https://github.com/opentrack/opentrack/pull/1754
49 (fetchpatch {
50 url = "https://github.com/opentrack/opentrack/commit/d501d7e0b237ed0c305525788b423d842ffa356d.patch";
51 hash = "sha256-XMGHV78vt/Xn3hS+4V//pqtsdBQCfJPjIXxfwtdXX+Q=";
52 })
53 ];
54
55 nativeBuildInputs = [
56 cmake
57 pkg-config
58 ninja
59 copyDesktopItems
60 ];
61 buildInputs = [
62 qtbase
63 qttools
64 opencv4
65 procps
66 eigen
67 libXdmcp
68 libevdev
69 aruco
70 onnxruntime
71 ]
72 ++ lib.optionals pkgs.stdenv.targetPlatform.isx86_64 [ wineWowPackages.stable ];
73
74 env.NIX_CFLAGS_COMPILE = "-Wall -Wextra -Wpedantic -ffast-math -O3";
75 dontWrapQtApps = true;
76
77 cmakeFlags = [
78 "-GNinja"
79 "-DCMAKE_BUILD_TYPE=Release"
80 "-DSDK_ARUCO_LIBPATH=${aruco}/lib/libaruco.a"
81 "-DSDK_XPLANE=${xplaneSdk}"
82 ]
83 ++ lib.optionals pkgs.stdenv.targetPlatform.isx86_64 [ "-DSDK_WINE=ON" ];
84
85 postInstall = ''
86 wrapQtApp $out/bin/opentrack
87 '';
88
89 desktopItems = [
90 (makeDesktopItem rec {
91 name = "opentrack";
92 exec = "opentrack";
93 icon = fetchurl {
94 url = "https://github.com/opentrack/opentrack/raw/opentrack-${version}/gui/images/opentrack.png";
95 hash = "sha256-9k3jToEpdW14ErbNGHM4c0x/LH7k14RmtvY4dOYnITQ=";
96 };
97 desktopName = name;
98 genericName = "Head tracking software";
99 categories = [ "Utility" ];
100 })
101 ];
102
103 meta = {
104 homepage = "https://github.com/opentrack/opentrack";
105 description = "Head tracking software for MS Windows, Linux, and Apple OSX";
106 mainProgram = "opentrack";
107 changelog = "https://github.com/opentrack/opentrack/releases/tag/${version}";
108 license = lib.licenses.isc;
109 maintainers = with lib.maintainers; [ zaninime ];
110 };
111}