1{
2 lib,
3 stdenv,
4 fetchFromGitLab,
5 fetchpatch2,
6 writeText,
7 bluez,
8 cjson,
9 cmake,
10 config,
11 dbus,
12 doxygen,
13 eigen,
14 elfutils,
15 glslang,
16 gst-plugins-base,
17 gstreamer,
18 hidapi,
19 libbsd,
20 libdrm,
21 libffi,
22 libGL,
23 libjpeg,
24 librealsense,
25 libsurvive,
26 libunwind,
27 libusb1,
28 libuv,
29 libuvc,
30 libv4l,
31 libXau,
32 libxcb,
33 libXdmcp,
34 libXext,
35 libXrandr,
36 nix-update-script,
37 onnxruntime,
38 opencv4,
39 openhmd,
40 openvr,
41 orc,
42 pcre2,
43 pkg-config,
44 python3,
45 SDL2,
46 shaderc,
47 tracy,
48 udev,
49 vulkan-headers,
50 vulkan-loader,
51 wayland,
52 wayland-protocols,
53 wayland-scanner,
54 zlib,
55 zstd,
56 nixosTests,
57 cudaPackages,
58 enableCuda ? config.cudaSupport,
59 # Set as 'false' to build monado without service support, i.e. allow VR
60 # applications linking against libopenxr_monado.so to use OpenXR standalone
61 # instead of via the monado-service program. For more information see:
62 # https://gitlab.freedesktop.org/monado/monado/-/blob/master/doc/targets.md#xrt_feature_service-disabled
63 serviceSupport ? true,
64 tracingSupport ? false,
65}:
66
67stdenv.mkDerivation (finalAttrs: {
68 pname = "monado";
69 version = "25.0.0";
70
71 src = fetchFromGitLab {
72 domain = "gitlab.freedesktop.org";
73 owner = "monado";
74 repo = "monado";
75 tag = "v${finalAttrs.version}";
76 hash = "sha256-VxTxvw+ftqlh3qF5qWxpK1OJsRowkRXu0xEH2bDckUA=";
77 };
78
79 patches = [
80 # Remove with v26
81 (fetchpatch2 {
82 url = "https://gitlab.freedesktop.org/monado/monado/-/commit/2a6932d46dad9aa957205e8a47ec2baa33041076.patch";
83 hash = "sha256-CZMbGgx7mEDcjcoRJHDZ5P6BecFW8CB4fpzxQ9bpAvE=";
84 })
85 ];
86
87 nativeBuildInputs = [
88 cmake
89 doxygen
90 glslang
91 pkg-config
92 python3
93 ];
94
95 # known disabled drivers/features:
96 # - DRIVER_DEPTHAI - Needs depthai-core https://github.com/luxonis/depthai-core (See https://github.com/NixOS/nixpkgs/issues/292618)
97 # - DRIVER_ILLIXR - needs ILLIXR headers https://github.com/ILLIXR/ILLIXR (See https://github.com/NixOS/nixpkgs/issues/292661)
98 # - DRIVER_ULV2 - Needs proprietary Leapmotion SDK https://api.leapmotion.com/documentation/v2/unity/devguide/Leap_SDK_Overview.html (See https://github.com/NixOS/nixpkgs/issues/292624)
99 # - DRIVER_ULV5 - Needs proprietary Leapmotion SDK https://api.leapmotion.com/documentation/v2/unity/devguide/Leap_SDK_Overview.html (See https://github.com/NixOS/nixpkgs/issues/292624)
100
101 buildInputs = [
102 bluez
103 cjson
104 dbus
105 eigen
106 elfutils
107 gst-plugins-base
108 gstreamer
109 hidapi
110 libbsd
111 libdrm
112 libffi
113 libGL
114 libjpeg
115 librealsense
116 libsurvive
117 libunwind
118 libusb1
119 libuv
120 libuvc
121 libv4l
122 libXau
123 libxcb
124 libXdmcp
125 libXext
126 libXrandr
127 onnxruntime
128 opencv4
129 openhmd
130 openvr
131 orc
132 pcre2
133 SDL2
134 shaderc
135 udev
136 vulkan-headers
137 vulkan-loader
138 wayland
139 wayland-protocols
140 wayland-scanner
141 zlib
142 zstd
143 ]
144 ++ lib.optionals tracingSupport [
145 tracy
146 ];
147
148 cmakeFlags = [
149 (lib.cmakeBool "XRT_FEATURE_SERVICE" serviceSupport)
150 (lib.cmakeBool "XRT_HAVE_TRACY" tracingSupport)
151 (lib.cmakeBool "XRT_FEATURE_TRACING" tracingSupport)
152 (lib.cmakeBool "XRT_OPENXR_INSTALL_ABSOLUTE_RUNTIME_PATH" true)
153 (lib.cmakeBool "XRT_HAVE_STEAM" true)
154 (lib.optionals enableCuda "-DCUDA_TOOLKIT_ROOT_DIR=${cudaPackages.cudatoolkit}")
155 ];
156
157 # Help openxr-loader find this runtime
158 setupHook = writeText "setup-hook" ''
159 export XDG_CONFIG_DIRS=@out@/etc/xdg''${XDG_CONFIG_DIRS:+:''${XDG_CONFIG_DIRS}}
160 '';
161
162 passthru = {
163 updateScript = nix-update-script { };
164 tests.basic-service = nixosTests.monado;
165 };
166
167 meta = {
168 description = "Open source XR runtime";
169 homepage = "https://monado.freedesktop.org/";
170 license = lib.licenses.boost;
171 maintainers = with lib.maintainers; [
172 Scrumplex
173 prusnak
174 ];
175 platforms = lib.platforms.linux;
176 mainProgram = "monado-cli";
177 };
178})