1{ lib
2, stdenv
3, fetchFromGitHub
4, cmake
5, vulkan-headers
6, vulkan-loader
7, glslang
8, opencv
9, protobuf
10}:
11
12stdenv.mkDerivation rec {
13 pname = "ncnn";
14 version = "20231027";
15
16 src = fetchFromGitHub {
17 owner = "Tencent";
18 repo = pname;
19 rev = version;
20 sha256 = "sha256-ak/5QTOptg5M2I+3olnrBK6JZ01haIE6oh+sagEboAc=";
21 };
22
23 patches = [
24 ./cmakelists.patch
25 ];
26
27 cmakeFlags = [
28 "-DNCNN_CMAKE_VERBOSE=1" # Only for debugging the build
29 "-DNCNN_SHARED_LIB=1"
30 "-DNCNN_ENABLE_LTO=1"
31 "-DNCNN_VULKAN=1"
32 "-DNCNN_BUILD_EXAMPLES=0"
33 "-DNCNN_BUILD_TOOLS=0"
34 "-DNCNN_SYSTEM_GLSLANG=1"
35 "-DNCNN_PYTHON=0" # Should be an attribute
36
37 "-DGLSLANG_TARGET_DIR=${glslang}/lib/cmake"
38 ];
39
40 nativeBuildInputs = [ cmake ];
41 buildInputs = [ vulkan-headers vulkan-loader glslang opencv protobuf ];
42
43 meta = with lib; {
44 description = "ncnn is a high-performance neural network inference framework optimized for the mobile platform";
45 homepage = "https://github.com/Tencent/ncnn";
46 license = licenses.bsd3;
47 maintainers = with maintainers; [ tilcreator ];
48 platforms = platforms.all;
49 };
50}