diff --git a/pkgs/by-name/ma/maa-assistant-arknights/fastdeploy-ppocr.nix b/pkgs/by-name/ma/maa-assistant-arknights/fastdeploy-ppocr.nix index 8cd3d355091e..53ac9fa3bfc1 100644 --- a/pkgs/by-name/ma/maa-assistant-arknights/fastdeploy-ppocr.nix +++ b/pkgs/by-name/ma/maa-assistant-arknights/fastdeploy-ppocr.nix @@ -1,14 +1,15 @@ -{ stdenv -, config -, pkgs -, lib -, fetchFromGitHub -, cmake -, eigen -, onnxruntime -, opencv -, cudaSupport ? config.cudaSupport -, cudaPackages ? { } +{ + stdenv, + config, + pkgs, + lib, + fetchFromGitHub, + cmake, + eigen, + onnxruntime, + opencv, + cudaSupport ? config.cudaSupport, + cudaPackages ? { }, }@inputs: let @@ -30,34 +31,42 @@ effectiveStdenv.mkDerivation (finalAttrs: { hash = "sha256-5TItnPDc5WShpZAgBYeqgI9KKkk3qw/M8HPMlq/H4BM="; }; - outputs = [ "out" "cmake" ]; + outputs = [ + "out" + "cmake" + ]; nativeBuildInputs = [ cmake eigen - ] ++ lib.optionals cudaSupport [ - cudaPackages.cuda_nvcc - ]; + ] ++ 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 - ]); + 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) - ]; + 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 @@ -67,7 +76,7 @@ effectiveStdenv.mkDerivation (finalAttrs: { meta = with lib; { description = "MaaAssistantArknights stripped-down version of FastDeploy"; homepage = "https://github.com/MaaAssistantArknights/FastDeploy"; - platforms = platforms.linux; + platforms = platforms.linux ++ platforms.darwin; license = licenses.asl20; broken = cudaSupport && stdenv.hostPlatform.system != "x86_64-linux"; }; diff --git a/pkgs/by-name/ma/maa-assistant-arknights/package.nix b/pkgs/by-name/ma/maa-assistant-arknights/package.nix index de41a0e03f5a..f6e5818e8bd6 100644 --- a/pkgs/by-name/ma/maa-assistant-arknights/package.nix +++ b/pkgs/by-name/ma/maa-assistant-arknights/package.nix @@ -1,24 +1,26 @@ -{ lib -, config -, callPackage -, stdenv -, fetchFromGitHub -, asio -, cmake -, eigen -, libcpr -, onnxruntime -, opencv -, isBeta ? false -, cudaSupport ? config.cudaSupport -, cudaPackages ? { } +{ + lib, + config, + callPackage, + stdenv, + overrideSDK, + fetchFromGitHub, + asio, + cmake, + libcpr, + onnxruntime, + opencv, + isBeta ? false, + cudaSupport ? config.cudaSupport, + cudaPackages ? { }, }: let fastdeploy = callPackage ./fastdeploy-ppocr.nix { }; sources = lib.importJSON ./pin.json; in -stdenv.mkDerivation (finalAttr: { +# https://github.com/NixOS/nixpkgs/issues/314160 +(if stdenv.isDarwin then overrideSDK stdenv "11.0" else stdenv).mkDerivation (finalAttr: { pname = "maa-assistant-arknights" + lib.optionalString isBeta "-beta"; version = if isBeta then sources.beta.version else sources.stable.version; @@ -33,24 +35,27 @@ stdenv.mkDerivation (finalAttr: { asio cmake fastdeploy.cmake - ] ++ lib.optionals cudaSupport [ - cudaPackages.cuda_nvcc - ]; + ] ++ 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 - ]); + 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.cmakeBool "BUILD_SHARED_LIBS" true) @@ -64,6 +69,10 @@ stdenv.mkDerivation (finalAttr: { passthru.updateScript = ./update.sh; + postPatch = '' + cp -v ${fastdeploy.cmake}/Findonnxruntime.cmake cmake/ + ''; + postInstall = '' mkdir -p $out/share/${finalAttr.pname} mv $out/{Python,resource} $out/share/${finalAttr.pname} @@ -74,6 +83,6 @@ stdenv.mkDerivation (finalAttr: { homepage = "https://github.com/MaaAssistantArknights/MaaAssistantArknights"; license = licenses.agpl3Only; maintainers = with maintainers; [ Cryolitia ]; - platforms = platforms.linux; + platforms = platforms.linux ++ platforms.darwin; }; }) diff --git a/pkgs/by-name/ma/maa-cli/package.nix b/pkgs/by-name/ma/maa-cli/package.nix index 47949052b883..1ef59d2fef9f 100644 --- a/pkgs/by-name/ma/maa-cli/package.nix +++ b/pkgs/by-name/ma/maa-cli/package.nix @@ -1,14 +1,16 @@ -{ lib -, stdenv -, rustPlatform -, fetchFromGitHub -, installShellFiles -, makeWrapper -, pkg-config -, openssl -, maa-assistant-arknights -, android-tools -, git +{ + lib, + stdenv, + rustPlatform, + fetchFromGitHub, + installShellFiles, + makeWrapper, + pkg-config, + openssl, + darwin, + maa-assistant-arknights, + android-tools, + git, }: rustPlatform.buildRustPackage rec { @@ -28,13 +30,22 @@ rustPlatform.buildRustPackage rec { pkg-config ]; - buildInputs = [ - openssl - ]; + buildInputs = + [ openssl ] + ++ lib.optionals stdenv.isDarwin ( + with darwin.apple_sdk.frameworks; + [ + Security + SystemConfiguration + ] + ); # https://github.com/MaaAssistantArknights/maa-cli/pull/126 buildNoDefaultFeatures = true; - buildFeatures = [ "git2" "core_installer" ]; + buildFeatures = [ + "git2" + "core_installer" + ]; cargoHash = "sha256-iy9myT3bVW1TXCZx3ddiiDoDXx5BWqeQnSsJ97bc4IA="; @@ -47,9 +58,12 @@ rustPlatform.buildRustPackage rec { 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 - ]}" + --prefix PATH : "${ + lib.makeBinPath [ + android-tools + git + ] + }" installShellCompletion --cmd maa \ --bash <($out/bin/maa complete bash) \ @@ -65,7 +79,7 @@ rustPlatform.buildRustPackage rec { description = "A simple CLI for MAA by Rust"; homepage = "https://github.com/MaaAssistantArknights/maa-cli"; license = licenses.agpl3Only; - platforms = platforms.linux; + platforms = platforms.linux ++ platforms.darwin; maintainers = with maintainers; [ Cryolitia ]; mainProgram = "maa"; };