1{ stdenv, lib, fetchFromGitHub, cmake, libusb1, pkg-config, freeglut, libGLU, libGL, libXi, libXmu
2, GLUT, Cocoa
3 }:
4
5stdenv.mkDerivation rec {
6 pname = "freenect";
7 version = "0.7.0";
8
9 src = fetchFromGitHub {
10 owner = "OpenKinect";
11 repo = "libfreenect";
12 rev = "v${version}";
13 sha256 = "sha256-Lb5mrl9jiI1Z9UOAlP+bBPNoKNxm5VSrFZRvifEfhoU=";
14 };
15
16 buildInputs = [ libusb1 freeglut libGLU libGL libXi libXmu ]
17 ++ lib.optionals stdenv.isDarwin [ GLUT Cocoa ];
18
19 nativeBuildInputs = [ cmake pkg-config ];
20
21 # see https://aur.archlinux.org/cgit/aur.git/commit/PKGBUILD?h=libfreenect&id=0d17db49ba64bcb9e3a4eed61cf55c9a5ceb97f1
22 patchPhase = lib.concatMapStrings (x: ''
23 substituteInPlace ${x} --replace "{GLUT_LIBRARY}" "{GLUT_LIBRARIES}"
24 '') [ "examples/CMakeLists.txt" "wrappers/cpp/CMakeLists.txt" ];
25
26 meta = {
27 description = "Drivers and libraries for the Xbox Kinect device on Windows, Linux, and macOS";
28 homepage = "http://openkinect.org";
29 license = with lib.licenses; [ gpl2 asl20 ];
30 maintainers = with lib.maintainers; [ bennofs ];
31 platforms = with lib.platforms; linux ++ darwin ;
32 };
33}