Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ config, lib, stdenv, fetchFromGitHub, cmake, pkg-config, xorg, libGLU
2, libGL, glew, ocl-icd, python3
3, cudaSupport ? config.cudaSupport or false, cudatoolkit
4 # For visibility mostly. The whole approach to cuda architectures and capabilities
5 # will be reworked soon.
6, cudaArch ? "compute_37"
7, openclSupport ? !cudaSupport
8, darwin
9}:
10
11stdenv.mkDerivation rec {
12 pname = "opensubdiv";
13 version = "3.5.0";
14
15 src = fetchFromGitHub {
16 owner = "PixarAnimationStudios";
17 repo = "OpenSubdiv";
18 rev = "v${lib.replaceStrings ["."] ["_"] version}";
19 sha256 = "sha256-pYD2HxAszE9Ux1xsSJ7s2R13U8ct5tDo3ZP7H0+F9Rc=";
20 };
21
22 outputs = [ "out" "dev" ];
23
24 nativeBuildInputs = [ cmake pkg-config ];
25 buildInputs =
26 [ libGLU libGL python3
27 # FIXME: these are not actually needed, but the configure script wants them.
28 glew xorg.libX11 xorg.libXrandr xorg.libXxf86vm xorg.libXcursor
29 xorg.libXinerama xorg.libXi
30 ]
31 ++ lib.optional (openclSupport && !stdenv.isDarwin) ocl-icd
32 ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [OpenCL Cocoa CoreVideo IOKit AppKit AGL ])
33 ++ lib.optional cudaSupport cudatoolkit;
34
35 cmakeFlags =
36 [ "-DNO_TUTORIALS=1"
37 "-DNO_REGRESSION=1"
38 "-DNO_EXAMPLES=1"
39 "-DNO_METAL=1" # don’t have metal in apple sdk
40 ] ++ lib.optionals (!stdenv.isDarwin) [
41 "-DGLEW_INCLUDE_DIR=${glew.dev}/include"
42 "-DGLEW_LIBRARY=${glew.dev}/lib"
43 ] ++ lib.optionals cudaSupport [
44 "-DOSD_CUDA_NVCC_FLAGS=--gpu-architecture=${cudaArch}"
45 "-DCUDA_HOST_COMPILER=${cudatoolkit.cc}/bin/cc"
46 ] ++ lib.optionals (!openclSupport) [
47 "-DNO_OPENCL=1"
48 ];
49
50 postInstall = "rm $out/lib/*.a";
51
52 meta = {
53 description = "An Open-Source subdivision surface library";
54 homepage = "http://graphics.pixar.com/opensubdiv";
55 broken = openclSupport && cudaSupport;
56 platforms = lib.platforms.unix;
57 maintainers = [ lib.maintainers.eelco ];
58 license = lib.licenses.asl20;
59 };
60}