nixpkgs/pkgs/by-name/ma/maa-cli/package.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

87 lines
2.2 KiB
Nix

{
lib,
stdenv,
rustPlatform,
fetchFromGitHub,
installShellFiles,
makeWrapper,
pkg-config,
openssl,
darwin,
maa-assistant-arknights,
android-tools,
git,
}:
rustPlatform.buildRustPackage rec {
pname = "maa-cli";
version = "0.4.12";
src = fetchFromGitHub {
owner = "MaaAssistantArknights";
repo = "maa-cli";
rev = "v${version}";
hash = "sha256-cq1FCsBHwcL8a51MswG/5TvyzSbtOvqw06OZfIXDVwg=";
};
nativeBuildInputs = [
installShellFiles
makeWrapper
pkg-config
];
buildInputs =
[ openssl ]
++ lib.optionals stdenv.hostPlatform.isDarwin (
with darwin.apple_sdk.frameworks;
[
Security
SystemConfiguration
]
);
# https://github.com/MaaAssistantArknights/maa-cli/pull/126
buildNoDefaultFeatures = true;
buildFeatures = [ "git2" ];
cargoHash = "sha256-eXgZt8sLbHkVNWqFv8Zdq7xrFBi1YhKI8Js0OT2Npi8=";
# 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
]
}"
''
+ lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
installShellCompletion --cmd maa \
--bash <($out/bin/maa complete bash) \
--fish <($out/bin/maa complete fish) \
--zsh <($out/bin/maa complete zsh)
mkdir -p manpage
$out/bin/maa mangen --path manpage
installManPage manpage/*
'';
meta = with lib; {
description = "Simple CLI for MAA by Rust";
homepage = "https://github.com/MaaAssistantArknights/maa-cli";
license = licenses.agpl3Only;
platforms = platforms.linux ++ platforms.darwin;
maintainers = with maintainers; [ Cryolitia ];
mainProgram = "maa";
};
}