about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/graphics/luxcorerender/default.nix
blob: 75e69a5d4996c0d020c618a5c891f324d9c054d2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
{ lib, config, stdenv, fetchFromGitHub, symlinkJoin, wrapGAppsHook, cmake, boost172
, pkg-config, flex, bison, libpng, libtiff, zlib, python3, embree, openexr
, openimagedenoise, openimageio, tbb, c-blosc, gtk3, pcre, doxygen
# OpenCL Support
, withOpenCL ? true, ocl-icd
# Cuda Support
, withCuda ? config.cudaSupport or false, cudatoolkit }:

let
  boostWithPython = boost172.override {
    enablePython = true;
    enableNumpy = true;
    python = python3;
  };

  # Requires a version number like "<MAJOR><MINOR>"
  pythonVersion = (lib.versions.major python3.version)
    + (lib.versions.minor python3.version);

in stdenv.mkDerivation rec {
  pname = "luxcorerender";
  version = "2.4";

  src = fetchFromGitHub {
    owner = "LuxCoreRender";
    repo = "LuxCore";
    rev = "luxcorerender_v${version}";
    sha256 = "0xvivw79719fa1q762b76nyvzawfd3hmp8y5j04bax8a7f8mfa9k";
  };

  nativeBuildInputs = [ pkg-config cmake flex bison doxygen wrapGAppsHook ];

  buildInputs = [
    libpng
    libtiff
    zlib
    boostWithPython.dev
    python3
    embree
    openexr
    openimagedenoise
    tbb
    c-blosc
    gtk3
    pcre
    openimageio.dev
    openimageio.out
  ] ++ lib.optionals withOpenCL [ ocl-icd ]
    ++ lib.optionals withCuda [ cudatoolkit ];

  cmakeFlags = [ "-DPYTHON_V=${pythonVersion}" ]
    ++ lib.optional (!withOpenCL) "-DLUXRAYS_DISABLE_OPENCL=1"
    ++ lib.optional (!withCuda) "-DLUXRAYS_DISABLE_CUDA=1";

  preConfigure = ''
    NIX_LDFLAGS+=" -lpython3"
  '';

  installPhase = ''
    mkdir -p $out/bin
    mkdir -p $out/lib
    cp -va bin/* $out/bin
    cp -va lib/* $out/lib
  '';

  meta = with lib; {
    description = "Open source, physically based, unbiased rendering engine";
    homepage = "https://luxcorerender.org/";
    maintainers = with maintainers; [ hodapp ];
    license = licenses.asl20;
    platforms = platforms.linux;
  };
}

# TODO (might not be necessary):
#
# luxcoreui still gives warnings like: "failed to commit changes to
# dconf: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The
# name ca.desrt.dconf was not provided by any .service files"

# CMake complains of the FindOpenGL/GLVND preference