1{ AppKit
2, cmake
3, fetchFromGitHub
4, fetchpatch2
5, Foundation
6, jsoncpp
7, lib
8, libGL
9, stdenv
10}:
11
12stdenv.mkDerivation (finalAttrs: {
13 pname = "openvr";
14 version = "1.26.7";
15
16 src = fetchFromGitHub {
17 owner = "ValveSoftware";
18 repo = "openvr";
19 rev = "v${finalAttrs.version}";
20 hash = "sha256-verVIRyDdpF8lIjjjG8GllDJG7nhqByIfs/8O5TMOyc=";
21 };
22
23 patches = [
24 # https://github.com/ValveSoftware/openvr/pull/594
25 (fetchpatch2 {
26 name = "use-correct-CPP11-definition-for-vsprintf_s.patch";
27 url = "https://github.com/ValveSoftware/openvr/commit/0fa21ba17748efcca1816536e27bdca70141b074.patch";
28 hash = "sha256-0sPNDx5qKqCzN35FfArbgJ0cTztQp+SMLsXICxneLx4=";
29 })
30 # https://github.com/ValveSoftware/openvr/pull/1716
31 (fetchpatch2 {
32 name = "add-ability-to-build-with-system-installed-jsoncpp.patch";
33 url = "https://github.com/ValveSoftware/openvr/commit/54a58e479f4d63e62e9118637cd92a2013a4fb95.patch";
34 hash = "sha256-aMojjbNjLvsGev0JaBx5sWuMv01sy2tG/S++I1NUi7U=";
35 })
36 ];
37
38 postUnpack = ''
39 # Move in-tree jsoncpp out to complement the patch above
40 # fetchpatch2 is not able to handle these renames
41 mkdir source/thirdparty
42 mv source/src/json source/thirdparty/jsoncpp
43 '';
44
45 nativeBuildInputs = [
46 cmake
47 ];
48
49 buildInputs = [
50 jsoncpp
51 libGL
52 ] ++ lib.optionals stdenv.isDarwin [
53 AppKit
54 Foundation
55 ];
56
57 cmakeFlags = [ "-DUSE_SYSTEM_JSONCPP=ON" "-DBUILD_SHARED=1" ];
58
59 meta = {
60 broken = stdenv.isDarwin;
61 description = "An API and runtime that allows access to VR hardware from multiple vendors without requiring that applications have specific knowledge of the hardware they are targeting";
62 homepage = "https://github.com/ValveSoftware/openvr";
63 license = lib.licenses.bsd3;
64 maintainers = with lib.maintainers; [ pedrohlc Scrumplex ];
65 platforms = lib.platforms.unix;
66 };
67})