Merge pull request #254916 from Cryolitia/maa
maa-assistant-arknights: init at 5.2.0, maa-cli: init at 0.4.4
This commit is contained in:
commit
16d1988121
5 changed files with 279 additions and 0 deletions
74
pkgs/by-name/ma/maa-assistant-arknights/fastdeploy-ppocr.nix
Normal file
74
pkgs/by-name/ma/maa-assistant-arknights/fastdeploy-ppocr.nix
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
{ stdenv
|
||||||
|
, config
|
||||||
|
, pkgs
|
||||||
|
, lib
|
||||||
|
, fetchFromGitHub
|
||||||
|
, cmake
|
||||||
|
, eigen
|
||||||
|
, onnxruntime
|
||||||
|
, opencv
|
||||||
|
, cudaSupport ? config.cudaSupport
|
||||||
|
, cudaPackages ? { }
|
||||||
|
}@inputs:
|
||||||
|
|
||||||
|
let
|
||||||
|
effectiveStdenv = if cudaSupport then cudaPackages.backendStdenv else inputs.stdenv;
|
||||||
|
cudaCapabilities = cudaPackages.cudaFlags.cudaCapabilities;
|
||||||
|
# E.g. [ "80" "86" "90" ]
|
||||||
|
cudaArchitectures = (builtins.map cudaPackages.cudaFlags.dropDot cudaCapabilities);
|
||||||
|
cudaArchitecturesString = lib.strings.concatStringsSep ";" cudaArchitectures;
|
||||||
|
in
|
||||||
|
effectiveStdenv.mkDerivation (finalAttrs: {
|
||||||
|
pname = "fastdeploy-ppocr";
|
||||||
|
version = "0-unstable-2023-10-09";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "Cryolitia";
|
||||||
|
repo = "FastDeploy";
|
||||||
|
# follows https://github.com/MaaAssistantArknights/MaaDeps/blob/master/vcpkg-overlay/ports/maa-fastdeploy/portfile.cmake#L4
|
||||||
|
rev = "2e68908141f6950bc5d22ba84f514e893cc238ea";
|
||||||
|
hash = "sha256-BWO4lKZhwNG6mbkC70hPgMNjabTnEV5XMo0bLV/gvQs=";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = [ "out" "cmake" ];
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
cmake
|
||||||
|
eigen
|
||||||
|
] ++ lib.optionals cudaSupport [
|
||||||
|
cudaPackages.cuda_nvcc
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs = [
|
||||||
|
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
|
||||||
|
]);
|
||||||
|
|
||||||
|
cmakeFlags = [
|
||||||
|
(lib.cmakeFeature "CMAKE_BUILD_TYPE" "None")
|
||||||
|
(lib.cmakeBool "BUILD_SHARED_LIBS" true)
|
||||||
|
] ++ lib.optionals cudaSupport [
|
||||||
|
(lib.cmakeFeature "CMAKE_CUDA_ARCHITECTURES" cudaArchitecturesString)
|
||||||
|
];
|
||||||
|
|
||||||
|
postInstall = ''
|
||||||
|
mkdir $cmake
|
||||||
|
install -Dm644 ${finalAttrs.src}/cmake/Findonnxruntime.cmake $cmake/
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = "MaaAssistantArknights stripped-down version of FastDeploy";
|
||||||
|
homepage = "https://github.com/MaaAssistantArknights/FastDeploy";
|
||||||
|
platforms = platforms.linux;
|
||||||
|
license = licenses.apsl20;
|
||||||
|
broken = cudaSupport && stdenv.hostPlatform.system != "x86_64-linux";
|
||||||
|
};
|
||||||
|
})
|
99
pkgs/by-name/ma/maa-assistant-arknights/package.nix
Normal file
99
pkgs/by-name/ma/maa-assistant-arknights/package.nix
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
{ lib
|
||||||
|
, config
|
||||||
|
, callPackage
|
||||||
|
, stdenv
|
||||||
|
, fetchFromGitHub
|
||||||
|
, asio
|
||||||
|
, cmake
|
||||||
|
, eigen
|
||||||
|
, libcpr
|
||||||
|
, onnxruntime
|
||||||
|
, opencv
|
||||||
|
, isBeta ? false
|
||||||
|
, cudaSupport ? config.cudaSupport
|
||||||
|
, cudaPackages ? { }
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
fastdeploy = callPackage ./fastdeploy-ppocr.nix { };
|
||||||
|
sources = lib.importJSON ./pin.json;
|
||||||
|
in
|
||||||
|
stdenv.mkDerivation (finalAttr: {
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
# https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=maa-assistant-arknights
|
||||||
|
postPatch = ''
|
||||||
|
substituteInPlace CMakeLists.txt \
|
||||||
|
--replace-fail 'RUNTIME DESTINATION .' ' ' \
|
||||||
|
--replace-fail 'LIBRARY DESTINATION .' ' ' \
|
||||||
|
--replace-fail 'PUBLIC_HEADER DESTINATION .' ' '
|
||||||
|
|
||||||
|
substituteInPlace CMakeLists.txt \
|
||||||
|
--replace-fail 'find_package(asio ' '# find_package(asio ' \
|
||||||
|
--replace-fail 'asio::asio' ' '
|
||||||
|
|
||||||
|
shopt -s globstar nullglob
|
||||||
|
|
||||||
|
substituteInPlace src/MaaCore/**/{*.h,*.cpp,*.hpp,*.cc} \
|
||||||
|
--replace 'onnxruntime/core/session/' ""
|
||||||
|
substituteInPlace CMakeLists.txt \
|
||||||
|
--replace-fail 'ONNXRuntime' 'onnxruntime'
|
||||||
|
|
||||||
|
cp -v ${fastdeploy.cmake}/Findonnxruntime.cmake cmake/
|
||||||
|
'';
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
asio
|
||||||
|
cmake
|
||||||
|
fastdeploy.cmake
|
||||||
|
] ++ lib.optionals cudaSupport [
|
||||||
|
cudaPackages.cuda_nvcc
|
||||||
|
];
|
||||||
|
|
||||||
|
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
|
||||||
|
]);
|
||||||
|
|
||||||
|
cmakeFlags = [
|
||||||
|
(lib.cmakeFeature "CMAKE_BUILD_TYPE" "None")
|
||||||
|
(lib.cmakeBool "USE_MAADEPS" false)
|
||||||
|
(lib.cmakeBool "BUILD_SHARED_LIBS" true)
|
||||||
|
(lib.cmakeBool "INSTALL_RESOURCE" true)
|
||||||
|
(lib.cmakeBool "INSTALL_PYTHON" true)
|
||||||
|
(lib.cmakeFeature "MAA_VERSION" "v${finalAttr.version}")
|
||||||
|
];
|
||||||
|
|
||||||
|
passthru.updateScript = ./update.sh;
|
||||||
|
|
||||||
|
postInstall = ''
|
||||||
|
mkdir -p $out/share/${finalAttr.pname}
|
||||||
|
mv $out/{Python,resource} $out/share/${finalAttr.pname}
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = "An Arknights assistant";
|
||||||
|
homepage = "https://github.com/MaaAssistantArknights/MaaAssistantArknights";
|
||||||
|
license = licenses.agpl3Only;
|
||||||
|
maintainers = with maintainers; [ Cryolitia ];
|
||||||
|
platforms = platforms.linux;
|
||||||
|
};
|
||||||
|
})
|
10
pkgs/by-name/ma/maa-assistant-arknights/pin.json
Normal file
10
pkgs/by-name/ma/maa-assistant-arknights/pin.json
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"stable": {
|
||||||
|
"version": "5.2.0",
|
||||||
|
"hash": "sha256-vxGJHm1StQNN+0IVlGMqKVKW56LH6KUC94utDn7FcNo="
|
||||||
|
},
|
||||||
|
"beta": {
|
||||||
|
"version": "5.2.0",
|
||||||
|
"hash": "sha256-vxGJHm1StQNN+0IVlGMqKVKW56LH6KUC94utDn7FcNo="
|
||||||
|
}
|
||||||
|
}
|
28
pkgs/by-name/ma/maa-assistant-arknights/update.sh
Executable file
28
pkgs/by-name/ma/maa-assistant-arknights/update.sh
Executable file
|
@ -0,0 +1,28 @@
|
||||||
|
#!/usr/bin/env -S nix shell nixpkgs#nix nixpkgs#curl nixpkgs#jq nixpkgs#nix-prefetch-github --command bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
directory="$(dirname $0 | xargs realpath)"
|
||||||
|
|
||||||
|
version_stable="$(curl "https://api.github.com/repos/MaaAssistantArknights/MaaAssistantArknights/releases/latest" | jq -r '.tag_name')"
|
||||||
|
|
||||||
|
hash_stable=$(nix-prefetch-github MaaAssistantArknights MaaAssistantArknights --rev ${version_stable} -v | jq -r .hash)
|
||||||
|
|
||||||
|
version_beta="$(curl "https://api.github.com/repos/MaaAssistantArknights/MaaAssistantArknights/releases?per_page=1" | jq -r '.[0].tag_name')"
|
||||||
|
|
||||||
|
hash_beta=$(nix-prefetch-github MaaAssistantArknights MaaAssistantArknights --rev ${version_beta} -v | jq -r .hash)
|
||||||
|
|
||||||
|
cat > $directory/pin.json << EOF
|
||||||
|
{
|
||||||
|
"stable": {
|
||||||
|
"version": "${version_stable#*v}",
|
||||||
|
"hash": "$hash_stable"
|
||||||
|
},
|
||||||
|
"beta": {
|
||||||
|
"version": "${version_beta#*v}",
|
||||||
|
"hash": "$hash_beta"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat $directory/pin.json
|
68
pkgs/by-name/ma/maa-cli/package.nix
Normal file
68
pkgs/by-name/ma/maa-cli/package.nix
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
{ lib
|
||||||
|
, stdenv
|
||||||
|
, rustPlatform
|
||||||
|
, fetchFromGitHub
|
||||||
|
, installShellFiles
|
||||||
|
, makeWrapper
|
||||||
|
, pkg-config
|
||||||
|
, openssl
|
||||||
|
, maa-assistant-arknights
|
||||||
|
, android-tools
|
||||||
|
, git
|
||||||
|
}:
|
||||||
|
|
||||||
|
rustPlatform.buildRustPackage rec {
|
||||||
|
pname = "maa-cli";
|
||||||
|
version = "0.4.4";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "MaaAssistantArknights";
|
||||||
|
repo = "maa-cli";
|
||||||
|
rev = "v${version}";
|
||||||
|
hash = "sha256-pAtv6gCLFKRwUQEF6kD2bCPGpQGzahsfq/tAnQjrZrw=";
|
||||||
|
};
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
installShellFiles
|
||||||
|
makeWrapper
|
||||||
|
pkg-config
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs = [
|
||||||
|
openssl
|
||||||
|
];
|
||||||
|
|
||||||
|
# https://github.com/MaaAssistantArknights/maa-cli/pull/126
|
||||||
|
buildNoDefaultFeatures = true;
|
||||||
|
buildFeatures = [ "git2" "core_installer" ];
|
||||||
|
|
||||||
|
cargoHash = "sha256-KjI/5vl7oKVtXYehGLgi9jcaO4Y/TceL498rCPGHMD0=";
|
||||||
|
|
||||||
|
# maa-cli would only seach libMaaCore.so and resources in itself's path
|
||||||
|
# https://github.com/MaaAssistantArknights/maa-cli/issues/67
|
||||||
|
postInstall = ''
|
||||||
|
mkdir -p $out/share/maa-assistant-arknights/
|
||||||
|
ln -s ${maa-assistant-arknights}/share/maa-assistant-arknights/* $out/share/maa-assistant-arknights/
|
||||||
|
ln -s ${maa-assistant-arknights}/lib/* $out/share/maa-assistant-arknights/
|
||||||
|
mv $out/bin/maa $out/share/maa-assistant-arknights/
|
||||||
|
|
||||||
|
makeWrapper $out/share/maa-assistant-arknights/maa $out/bin/maa \
|
||||||
|
--prefix PATH : "${lib.makeBinPath [
|
||||||
|
android-tools git
|
||||||
|
]}"
|
||||||
|
|
||||||
|
installShellCompletion --cmd maa \
|
||||||
|
--bash <($out/bin/maa complete bash) \
|
||||||
|
--fish <($out/bin/maa complete fish) \
|
||||||
|
--zsh <($out/bin/maa complete zsh)
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = "A simple CLI for MAA by Rust";
|
||||||
|
homepage = "https://github.com/MaaAssistantArknights/maa-cli";
|
||||||
|
license = licenses.agpl3Plus;
|
||||||
|
platforms = platforms.linux;
|
||||||
|
maintainers = with maintainers; [ Cryolitia ];
|
||||||
|
mainProgram = "maa";
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue