acr-cli: init at 0.14 (#359508)
[NixPkgs.git] / pkgs / by-name / ma / maa-assistant-arknights / package.nix
blob32d43f3d05b140ba42f57f5717a2ea2c7c13dffc
2   lib,
3   config,
4   callPackage,
5   stdenv,
6   overrideSDK,
7   fetchFromGitHub,
8   asio,
9   cmake,
10   libcpr,
11   onnxruntime,
12   opencv,
13   isBeta ? false,
14   cudaSupport ? config.cudaSupport,
15   cudaPackages ? { },
18 let
19   fastdeploy = callPackage ./fastdeploy-ppocr.nix { };
20   sources = lib.importJSON ./pin.json;
22 # https://github.com/NixOS/nixpkgs/issues/314160
23 (if stdenv.hostPlatform.isDarwin then overrideSDK stdenv "11.0" else stdenv).mkDerivation
24   (finalAttr: {
25     pname = "maa-assistant-arknights" + lib.optionalString isBeta "-beta";
26     version = if isBeta then sources.beta.version else sources.stable.version;
28     src = fetchFromGitHub {
29       owner = "MaaAssistantArknights";
30       repo = "MaaAssistantArknights";
31       rev = "v${finalAttr.version}";
32       hash = if isBeta then sources.beta.hash else sources.stable.hash;
33     };
35     nativeBuildInputs = [
36       asio
37       cmake
38       fastdeploy.cmake
39     ] ++ lib.optionals cudaSupport [ cudaPackages.cuda_nvcc ];
41     buildInputs =
42       [
43         fastdeploy
44         libcpr
45         onnxruntime
46         opencv
47       ]
48       ++ lib.optionals cudaSupport (
49         with cudaPackages;
50         [
51           cuda_cccl # cub/cub.cuh
52           libcublas # cublas_v2.h
53           libcurand # curand.h
54           libcusparse # cusparse.h
55           libcufft # cufft.h
56           cudnn # cudnn.h
57           cuda_cudart
58         ]
59       );
61     cmakeBuildType = "None";
63     cmakeFlags = [
64       (lib.cmakeBool "BUILD_SHARED_LIBS" true)
65       (lib.cmakeBool "INSTALL_FLATTEN" false)
66       (lib.cmakeBool "INSTALL_PYTHON" true)
67       (lib.cmakeBool "INSTALL_RESOURCE" true)
68       (lib.cmakeBool "USE_MAADEPS" false)
69       (lib.cmakeFeature "MAA_VERSION" "v${finalAttr.version}")
70     ];
72     passthru.updateScript = ./update.sh;
74     postPatch = ''
75       cp -v ${fastdeploy.cmake}/Findonnxruntime.cmake cmake/
76     '';
78     postInstall = ''
79       mkdir -p $out/share/${finalAttr.pname}
80       mv $out/{Python,resource} $out/share/${finalAttr.pname}
81     '';
83     meta = with lib; {
84       description = "Arknights assistant";
85       homepage = "https://github.com/MaaAssistantArknights/MaaAssistantArknights";
86       license = licenses.agpl3Only;
87       maintainers = with maintainers; [ Cryolitia ];
88       platforms = platforms.linux ++ platforms.darwin;
89     };
90   })