1{ lib
2, stdenv
3, cmake
4, libGL
5, jsoncpp
6, fetchFromGitHub
7, fetchpatch2
8, Foundation
9, AppKit
10}:
11
12stdenv.mkDerivation rec {
13 pname = "openvr";
14 version = "1.23.8";
15
16 src = fetchFromGitHub {
17 owner = "ValveSoftware";
18 repo = pname;
19 rev = "v${version}";
20 hash = "sha256-ZdL1HDRSpPykbV3M0CjCZkOt7XlF7Z7OAhOey2ALeHg=";
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 sha256 = "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 sha256 = "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 = [ cmake ];
46 buildInputs = [ jsoncpp libGL ] ++ lib.optionals stdenv.isDarwin [ Foundation AppKit ];
47
48 cmakeFlags = [ "-DUSE_SYSTEM_JSONCPP=ON" "-DBUILD_SHARED=1" ];
49
50 meta = with lib; {
51 broken = stdenv.isDarwin;
52 homepage = "https://github.com/ValveSoftware/openvr";
53 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";
54 license = licenses.bsd3;
55 maintainers = with maintainers; [ pedrohlc Scrumplex ];
56 platforms = platforms.unix;
57 };
58}