diff --git a/pkgs/by-name/mi/mihomo-party/package.nix b/pkgs/by-name/mi/mihomo-party/package.nix index 1a879e408e93..8c46298a4005 100644 --- a/pkgs/by-name/mi/mihomo-party/package.nix +++ b/pkgs/by-name/mi/mihomo-party/package.nix @@ -15,15 +15,31 @@ libGL, }: let - pname = "mihomo-party"; - version = "1.4.5"; - src = fetchurl { - url = "https://github.com/mihomo-party-org/mihomo-party/releases/download/v${version}/mihomo-party-linux-${version}-amd64.deb"; - hash = "sha256-O332nt2kgpDGY84S78Tx2PGUw1Pyj80ab2ZE3woYm4Y="; - }; + version = "1.5.12"; + src = + let + inherit (stdenv.hostPlatform) system; + selectSystem = attrs: attrs.${system}; + suffix = selectSystem { + x86_64-linux = "amd64"; + aarch64-linux = "arm64"; + }; + hash = selectSystem { + x86_64-linux = "sha256-1vJ2FcJOcpNyfSm5HyLkexsULBBPlI0AW2jXuhK8khA="; + aarch64-linux = "sha256-P+zCO6HxcQJAGIVxOSRga+1Bqtn31mw2v+/EyEDpgF8="; + }; + in + fetchurl { + url = "https://github.com/mihomo-party-org/mihomo-party/releases/download/v${version}/mihomo-party-linux-${version}-${suffix}.deb"; + inherit hash; + }; in stdenv.mkDerivation { - inherit pname version src; + inherit version src; + + pname = "mihomo-party"; + + passthru.updateScript = ./update.sh; nativeBuildInputs = [ dpkg @@ -70,8 +86,10 @@ stdenv.mkDerivation { description = "Another Mihomo GUI"; homepage = "https://github.com/mihomo-party-org/mihomo-party"; mainProgram = "mihomo-party"; - platforms = with lib.platforms; linux ++ darwin; - broken = !(stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isx86_64); + platforms = [ + "aarch64-linux" + "x86_64-linux" + ]; license = lib.licenses.gpl3Plus; sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; maintainers = with lib.maintainers; [ aucub ]; diff --git a/pkgs/by-name/mi/mihomo-party/update.sh b/pkgs/by-name/mi/mihomo-party/update.sh new file mode 100755 index 000000000000..380b997c2512 --- /dev/null +++ b/pkgs/by-name/mi/mihomo-party/update.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p bash nixVersions.latest curl coreutils jq common-updater-scripts + +latestTag=$(curl ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} -sL https://api.github.com/repos/mihomo-party-org/mihomo-party/releases/latest | jq -r ".tag_name") +latestVersion="$(expr "$latestTag" : 'v\(.*\)')" +currentVersion=$(nix-instantiate --eval -E "with import ./. {}; mihomo-party.version" | tr -d '"') + +echo "latest version: $latestVersion" +echo "current version: $currentVersion" + +if [[ "$latestVersion" == "$currentVersion" ]]; then + echo "package is up-to-date" + exit 0 +fi + +for i in \ + "x86_64-linux amd64" \ + "aarch64-linux arm64"; do + set -- $i + prefetch=$(nix-prefetch-url "https://github.com/mihomo-party-org/mihomo-party/releases/download/v$latestVersion/mihomo-party-linux-$latestVersion-$2.deb") + hash=$(nix hash convert --hash-algo sha256 --to sri $prefetch) + update-source-version mihomo-party $latestVersion $hash --system=$1 --ignore-same-version +done