1 { config, lib, stdenv, fetchFromGitHub, cmake, pkg-config, xorg, libGLU
2 , libGL, glew, ocl-icd, python3
3 , cudaSupport ? config.cudaSupport, 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
11 stdenv.mkDerivation rec {
15 src = fetchFromGitHub {
16 owner = "PixarAnimationStudios";
18 rev = "v${lib.replaceStrings ["."] ["_"] version}";
19 sha256 = "sha256-uDKCT0Uoa5WQekMUFm2iZmzm+oWAZ6IWMwfpchkUZY0=";
22 outputs = [ "out" "dev" ];
24 nativeBuildInputs = [ cmake pkg-config ];
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
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;
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) [
50 preBuild = let maxBuildCores = 16; in lib.optionalString cudaSupport ''
51 # https://github.com/PixarAnimationStudios/OpenSubdiv/issues/1313
52 NIX_BUILD_CORES=$(( NIX_BUILD_CORES < ${toString maxBuildCores} ? NIX_BUILD_CORES : ${toString maxBuildCores} ))
55 postInstall = "rm $out/lib/*.a";
58 description = "An Open-Source subdivision surface library";
59 homepage = "http://graphics.pixar.com/opensubdiv";
60 broken = openclSupport && cudaSupport;
61 platforms = lib.platforms.unix;
62 maintainers = [ lib.maintainers.eelco ];
63 license = lib.licenses.asl20;