2024-06-20 14:57:18 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
callPackage,
|
|
|
|
stdenv,
|
|
|
|
overrideSDK,
|
|
|
|
fetchFromGitHub,
|
|
|
|
asio,
|
|
|
|
cmake,
|
|
|
|
libcpr,
|
|
|
|
onnxruntime,
|
|
|
|
opencv,
|
|
|
|
isBeta ? false,
|
|
|
|
cudaSupport ? config.cudaSupport,
|
|
|
|
cudaPackages ? { },
|
2024-04-21 15:54:59 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
fastdeploy = callPackage ./fastdeploy-ppocr.nix { };
|
|
|
|
sources = lib.importJSON ./pin.json;
|
|
|
|
in
|
2024-06-20 14:57:18 +00:00
|
|
|
# https://github.com/NixOS/nixpkgs/issues/314160
|
|
|
|
(if stdenv.isDarwin then overrideSDK stdenv "11.0" else stdenv).mkDerivation (finalAttr: {
|
2024-04-21 15:54:59 +00:00
|
|
|
pname = "maa-assistant-arknights" + lib.optionalString isBeta "-beta";
|
|
|
|
version = if isBeta then sources.beta.version else sources.stable.version;
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "MaaAssistantArknights";
|
|
|
|
repo = "MaaAssistantArknights";
|
|
|
|
rev = "v${finalAttr.version}";
|
|
|
|
hash = if isBeta then sources.beta.hash else sources.stable.hash;
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
asio
|
|
|
|
cmake
|
|
|
|
fastdeploy.cmake
|
2024-06-20 14:57:18 +00:00
|
|
|
] ++ lib.optionals cudaSupport [ cudaPackages.cuda_nvcc ];
|
2024-04-21 15:54:59 +00:00
|
|
|
|
2024-06-20 14:57:18 +00:00
|
|
|
buildInputs =
|
|
|
|
[
|
|
|
|
fastdeploy
|
|
|
|
libcpr
|
|
|
|
onnxruntime
|
|
|
|
opencv
|
|
|
|
]
|
|
|
|
++ lib.optionals cudaSupport (
|
|
|
|
with cudaPackages;
|
|
|
|
[
|
|
|
|
cuda_cccl # cub/cub.cuh
|
|
|
|
libcublas # cublas_v2.h
|
|
|
|
libcurand # curand.h
|
|
|
|
libcusparse # cusparse.h
|
|
|
|
libcufft # cufft.h
|
|
|
|
cudnn # cudnn.h
|
|
|
|
cuda_cudart
|
|
|
|
]
|
|
|
|
);
|
2024-04-21 15:54:59 +00:00
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
(lib.cmakeBool "BUILD_SHARED_LIBS" true)
|
2024-06-05 15:53:02 +00:00
|
|
|
(lib.cmakeBool "INSTALL_FLATTEN" false)
|
2024-04-21 15:54:59 +00:00
|
|
|
(lib.cmakeBool "INSTALL_PYTHON" true)
|
2024-06-05 15:53:02 +00:00
|
|
|
(lib.cmakeBool "INSTALL_RESOURCE" true)
|
|
|
|
(lib.cmakeBool "USE_MAADEPS" false)
|
|
|
|
(lib.cmakeFeature "CMAKE_BUILD_TYPE" "None")
|
2024-04-21 15:54:59 +00:00
|
|
|
(lib.cmakeFeature "MAA_VERSION" "v${finalAttr.version}")
|
|
|
|
];
|
|
|
|
|
|
|
|
passthru.updateScript = ./update.sh;
|
|
|
|
|
2024-06-20 14:57:18 +00:00
|
|
|
postPatch = ''
|
|
|
|
cp -v ${fastdeploy.cmake}/Findonnxruntime.cmake cmake/
|
|
|
|
'';
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
postInstall = ''
|
|
|
|
mkdir -p $out/share/${finalAttr.pname}
|
|
|
|
mv $out/{Python,resource} $out/share/${finalAttr.pname}
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Arknights assistant";
|
2024-04-21 15:54:59 +00:00
|
|
|
homepage = "https://github.com/MaaAssistantArknights/MaaAssistantArknights";
|
|
|
|
license = licenses.agpl3Only;
|
|
|
|
maintainers = with maintainers; [ Cryolitia ];
|
2024-06-20 14:57:18 +00:00
|
|
|
platforms = platforms.linux ++ platforms.darwin;
|
2024-04-21 15:54:59 +00:00
|
|
|
};
|
|
|
|
})
|