1 { lib, stdenv, fetchFromBitbucket, cmake, nasm, numactl
2 , numaSupport ? stdenv.hostPlatform.isLinux && (stdenv.hostPlatform.isx86 || stdenv.hostPlatform.isAarch64) # Enabled by default on NUMA platforms
3 , debugSupport ? false # Run-time sanity checks (debugging)
4 , werrorSupport ? false # Warnings as errors
5 , ppaSupport ? false # PPA profiling instrumentation
6 , vtuneSupport ? false # Vtune profiling instrumentation
7 , custatsSupport ? false # Internal profiling of encoder work
8 , cliSupport ? true # Build standalone CLI application
9 , unittestsSupport ? false # Unit tests
13 mkFlag = optSet: flag: if optSet then "-D${flag}=ON" else "-D${flag}=OFF";
14 inherit (stdenv) is64bit;
17 "-DSTATIC_LINK_CRT=OFF"
18 (mkFlag debugSupport "CHECKED_BUILD")
19 (mkFlag ppaSupport "ENABLE_PPA")
20 (mkFlag vtuneSupport "ENABLE_VTUNE")
21 (mkFlag custatsSupport "DETAILED_CU_STATS")
22 (mkFlag unittestsSupport "ENABLE_TESTS")
23 (mkFlag werrorSupport "WARNINGS_AS_ERRORS")
24 ] ++ lib.optionals stdenv.hostPlatform.isPower [
25 "-DENABLE_ALTIVEC=OFF"
30 src = fetchFromBitbucket {
31 owner = "multicoreware";
34 sha256 = "1jzgv2hxhcwmsdf6sbgyzm88a46dp09ll1fqj92g9vckvh9a7dsn";
37 buildLib = has12Bit: stdenv.mkDerivation rec {
38 name = "libx265-${if has12Bit then "12" else "10"}-${version}";
42 sed -i 's/unknown/${version}/g' source/cmake/version.cmake
43 sed -i 's/0.0/${version}/g' source/cmake/version.cmake
49 "-DENABLE_HDR10_PLUS=ON"
53 cmakeFlags = [(mkFlag has12Bit "MAIN12")] ++ cmakeLibFlags ++ cmakeFlagsAll;
59 nativeBuildInputs = [cmake nasm] ++ lib.optional numaSupport numactl;
62 libx265-10 = buildLib false;
63 libx265-12 = buildLib true;
66 stdenv.mkDerivation rec {
71 sed -i 's/unknown/${version}/g' source/cmake/version.cmake
72 sed -i 's/0.0/${version}/g' source/cmake/version.cmake
77 "-DHIGH_BIT_DEPTH=OFF"
78 "-DENABLE_HDR10_PLUS=OFF"
79 ] ++ lib.optionals (is64bit && !(stdenv.isAarch64 && stdenv.isLinux)) [
80 "-DEXTRA_LIB=${libx265-10}/lib/libx265.a;${libx265-12}/lib/libx265.a"
84 (mkFlag cliSupport "ENABLE_CLI")
95 nativeBuildInputs = [ cmake nasm ] ++ lib.optional numaSupport numactl;
98 description = "Library for encoding h.265/HEVC video streams";
99 homepage = "http://x265.org";
100 license = licenses.gpl2;
101 maintainers = with maintainers; [ codyopel ];
102 platforms = platforms.all;