summaryrefslogtreecommitdiff
path: root/pkgs/by-name/wi/wivrn/package.nix
blob: a55ee1dc5cf4e8e53bb8966fa36e4840c6ecc569 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
{
  # Commented packages are not currently in nixpkgs. They don't appear to cause a problem when not present.
  config,
  lib,
  stdenv,
  fetchFromGitHub,
  fetchFromGitLab,
  applyPatches,
  autoAddDriverRunpath,
  avahi,
  bluez,
  boost,
  cjson,
  cli11,
  cmake,
  cudaPackages ? { },
  cudaSupport ? config.cudaSupport,
  dbus,
  # depthai
  doxygen,
  eigen,
  elfutils,
  ffmpeg,
  freetype,
  git,
  glib,
  glm,
  glslang,
  gst_all_1,
  harfbuzz,
  hidapi,
  kdePackages,
  # leapsdk
  # leapv2
  libGL,
  libX11,
  libXrandr,
  libbsd,
  libdrm,
  libjpeg,
  libmd,
  libnotify,
  libpulseaudio,
  librealsense,
  librsvg,
  libsurvive,
  libunwind,
  libusb1,
  libuvc,
  libva,
  makeDesktopItem,
  nix-update-script,
  nlohmann_json,
  onnxruntime,
  opencomposite,
  opencv4,
  openhmd,
  openvr,
  openxr-loader,
  orc,
  # percetto
  pipewire,
  pkg-config,
  python3,
  qt6,
  SDL2,
  shaderc,
  spdlog,
  systemd,
  udev,
  vulkan-headers,
  vulkan-loader,
  wayland,
  wayland-protocols,
  wayland-scanner,
  x264,
}:
stdenv.mkDerivation (finalAttrs: {
  pname = "wivrn";
  version = "0.23.2";

  src = fetchFromGitHub {
    owner = "wivrn";
    repo = "wivrn";
    rev = "v${finalAttrs.version}";
    hash = "sha256-KpsS0XssSnE2Fj5rrXq1h+yNHhF7BzfPxwRUhZUZEaw=";
  };

  monado = applyPatches {
    src = fetchFromGitLab {
      domain = "gitlab.freedesktop.org";
      owner = "monado";
      repo = "monado";
      rev = "848a24aa106758fd6c7afcab6d95880c57dbe450";
      hash = "sha256-+rax9/CG/3y8rLYwGqoWJa4FxH+Z3eREiwhuxDOUzLs=";
    };

    patches = [
      ./force-enable-steamvr_lh.patch
    ];

    postPatch = ''
      ${finalAttrs.src}/patches/apply.sh ${finalAttrs.src}/patches/monado/*
    '';
  };

  strictDeps = true;

  postUnpack = ''
    # Let's make sure our monado source revision matches what is used by WiVRn upstream
    ourMonadoRev="${finalAttrs.monado.src.rev}"
    theirMonadoRev=$(sed -n '/FetchContent_Declare(monado/,/)/p' ${finalAttrs.src.name}/CMakeLists.txt | grep "GIT_TAG" | awk '{print $2}')
    if [ ! "$theirMonadoRev" == "$ourMonadoRev" ]; then
      echo "Our Monado source revision doesn't match CMakeLists.txt." >&2
      echo "  theirs: $theirMonadoRev" >&2
      echo "    ours: $ourMonadoRev" >&2
      return 1
    fi
  '';

  nativeBuildInputs =
    [
      cmake
      doxygen
      git
      glib
      glslang
      librsvg
      pkg-config
      python3
      qt6.wrapQtAppsHook
    ]
    ++ lib.optionals cudaSupport [
      autoAddDriverRunpath
    ];

  buildInputs =
    [
      avahi
      boost
      bluez
      cjson
      cli11
      dbus
      eigen
      elfutils
      ffmpeg
      freetype
      glib
      glm
      gst_all_1.gst-plugins-base
      gst_all_1.gstreamer
      harfbuzz
      hidapi
      kdePackages.kcoreaddons
      kdePackages.ki18n
      kdePackages.kiconthemes
      kdePackages.kirigami
      kdePackages.qcoro
      kdePackages.qqc2-desktop-style
      libbsd
      libdrm
      libGL
      libjpeg
      libmd
      libnotify
      librealsense
      libsurvive
      libunwind
      libusb1
      libuvc
      libva
      libX11
      libXrandr
      libpulseaudio
      nlohmann_json
      opencv4
      openhmd
      openvr
      openxr-loader
      onnxruntime
      orc
      pipewire
      qt6.qtbase
      qt6.qtsvg
      qt6.qttools
      SDL2
      shaderc
      spdlog
      systemd
      udev
      vulkan-headers
      vulkan-loader
      wayland
      wayland-protocols
      wayland-scanner
      x264
    ]
    ++ lib.optionals cudaSupport [
      cudaPackages.cudatoolkit
    ];

  cmakeFlags =
    [
      (lib.cmakeBool "WIVRN_USE_NVENC" cudaSupport)
      (lib.cmakeBool "WIVRN_USE_VAAPI" true)
      (lib.cmakeBool "WIVRN_USE_VULKAN_ENCODE" true)
      (lib.cmakeBool "WIVRN_USE_X264" true)
      (lib.cmakeBool "WIVRN_USE_PIPEWIRE" true)
      (lib.cmakeBool "WIVRN_USE_PULSEAUDIO" true)
      (lib.cmakeBool "WIVRN_FEATURE_STEAMVR_LIGHTHOUSE" true)
      (lib.cmakeBool "WIVRN_BUILD_CLIENT" false)
      (lib.cmakeBool "WIVRN_BUILD_DASHBOARD" true)
      (lib.cmakeBool "WIVRN_CHECK_CAPSYSNICE" false)
      (lib.cmakeBool "FETCHCONTENT_FULLY_DISCONNECTED" true)
      (lib.cmakeFeature "WIVRN_OPENXR_MANIFEST_TYPE" "absolute")
      (lib.cmakeFeature "OPENCOMPOSITE_SEARCH_PATH" "${opencomposite}/lib/opencomposite")
      (lib.cmakeFeature "GIT_DESC" "v${finalAttrs.version}")
      (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_MONADO" "${finalAttrs.monado}")
    ]
    ++ lib.optionals cudaSupport [
      (lib.cmakeFeature "CUDA_TOOLKIT_ROOT_DIR" "${cudaPackages.cudatoolkit}")
    ];

  postFixup = ''
    wrapProgram $out/bin/wivrn-dashboard \
      --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ vulkan-loader ]}
  '';

  desktopItems = [
    (makeDesktopItem {
      name = "WiVRn Server";
      desktopName = "WiVRn Server";
      genericName = "WiVRn Server";
      comment = "Play your PC VR games on a standalone headset";
      icon = "io.github.wivrn.wivrn";
      exec = "wivrn-dashboard";
      type = "Application";
      categories = [ "Network" ];
    })
  ];

  passthru.updateScript = nix-update-script { };

  meta = with lib; {
    description = "An OpenXR streaming application to a standalone headset";
    homepage = "https://github.com/WiVRn/WiVRn/";
    changelog = "https://github.com/WiVRn/WiVRn/releases/";
    license = licenses.gpl3Only;
    maintainers = with maintainers; [ passivelemon ];
    platforms = platforms.linux;
    mainProgram = "wivrn-server";
    sourceProvenance = with sourceTypes; [ fromSource ];
  };
})