Commit 09e97e00 authored by lyranico's avatar lyranico Committed by GitHub
Browse files

mihomo-party: refactor

parent 2da5248f
Loading
Loading
Loading
Loading
+17 −18
Original line number Diff line number Diff line
@@ -13,32 +13,28 @@
  libayatana-appindicator,
  libGL,
}:
let

stdenv.mkDerivation rec {
  pname = "mihomo-party";
  version = "1.7.1";

  src =
    let
      inherit (stdenv.hostPlatform) system;
      selectSystem = attrs: attrs.${system};
      suffix = selectSystem {
      selectSystem =
        attrs:
        attrs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
      arch = selectSystem {
        x86_64-linux = "amd64";
        aarch64-linux = "arm64";
      };
    in
    fetchurl {
      url = "https://github.com/mihomo-party-org/mihomo-party/releases/download/v${version}/mihomo-party-linux-${version}-${arch}.deb";
      hash = selectSystem {
        x86_64-linux = "sha256-fVPW4lk+1uY+zTPk0wNeHz7ILKB+7p9hunHrqnuPI6w=";
        aarch64-linux = "sha256-wEOOP5ha7R0z0DCTCsmn5lfwJdzEWtNGdWNjVB5cI6k=";
      };
    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 version src;

  pname = "mihomo-party";

  passthru.updateScript = ./update.sh;

  nativeBuildInputs = [
    dpkg
@@ -58,10 +54,11 @@ stdenv.mkDerivation {
    runHook preInstall

    mkdir -p $out/bin
    cp -r opt/mihomo-party usr/share $out
    cp -r opt $out/opt
    cp -r usr/share $out/share
    substituteInPlace $out/share/applications/mihomo-party.desktop \
      --replace-fail "/opt/mihomo-party/mihomo-party" "mihomo-party"
    ln -s $out/mihomo-party/mihomo-party $out/bin/mihomo-party
    ln -s $out/opt/mihomo-party/mihomo-party $out/bin/mihomo-party

    runHook postInstall
  '';
@@ -74,9 +71,11 @@ stdenv.mkDerivation {
          udev
          libayatana-appindicator
        ]
      } $out/mihomo-party/mihomo-party
      } $out/opt/mihomo-party/mihomo-party
  '';

  passthru.updateScript = ./update.sh;

  meta = {
    description = "Another Mihomo GUI";
    homepage = "https://github.com/mihomo-party-org/mihomo-party";
+1 −1
Original line number Diff line number Diff line
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash nixVersions.latest curl coreutils jq common-updater-scripts
#!nix-shell -i bash -p bash nix 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\(.*\)')"