1{ llvmPackages, lib, fetchFromGitHub, cmake
2, libpng, libjpeg, mesa_noglu, eigen, openblas
3}:
4
5let
6 version = "2018_02_15";
7
8in llvmPackages.stdenv.mkDerivation {
9
10 name = "halide-${builtins.replaceStrings ["_"] ["."] version}";
11
12 src = fetchFromGitHub {
13 owner = "halide";
14 repo = "Halide";
15 rev = "release_${version}";
16 sha256 = "14lmpbxydx7ii0pxds6rgq5vw4i6yfjsq0bai1l5wwpv1rnwmbxd";
17 };
18
19 patches = [ ./nix.patch ];
20
21 # clang fails to compile intermediate code because
22 # of unused "--gcc-toolchain" option
23 postPatch = ''
24 sed -i "s/-Werror//" src/CMakeLists.txt
25 '';
26
27 cmakeFlags = [ "-DWARNINGS_AS_ERRORS=OFF" ];
28
29 # To handle the lack of 'local' RPATH; required, as they call one of
30 # their built binaries requiring their libs, in the build process.
31 preBuild = ''
32 export LD_LIBRARY_PATH="$(pwd)/lib:$LD_LIBRARY_PATH"
33 '';
34
35 enableParallelBuilding = true;
36
37 # Note: only openblas and not atlas part of this Nix expression
38 # see pkgs/development/libraries/science/math/liblapack/3.5.0.nix
39 # to get a hint howto setup atlas instead of openblas
40 buildInputs = [ llvmPackages.llvm libpng libjpeg mesa_noglu eigen openblas ];
41
42 nativeBuildInputs = [ cmake ];
43
44 # No install target for cmake available.
45 # Calling install target in Makefile causes complete rebuild
46 # and the library rpath is broken, because libncursesw.so.6 is missing.
47 # Another way is using "make halide_archive", but the tarball is not easy
48 # to disassemble.
49 installPhase = ''
50 find
51 mkdir -p "$out/lib" "$out/bin"
52 cp bin/HalideTrace* "$out/bin"
53 cp lib/libHalide.so "$out/lib"
54 cp -r include "$out"
55 '';
56
57 meta = with lib; {
58 description = "C++ based language for image processing and computational photography";
59 homepage = "https://halide-lang.org";
60 license = licenses.mit;
61 platforms = platforms.linux;
62 maintainers = [ maintainers.ck3d ];
63 };
64}