From 9aae517513c32643717a82a505a92aecb647f88e Mon Sep 17 00:00:00 2001 From: lyranico Date: Tue, 11 Feb 2025 02:52:23 +0800 Subject: [PATCH 1/3] mihomo-party: remove wrapGAppsHook3 --- pkgs/by-name/mi/mihomo-party/package.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkgs/by-name/mi/mihomo-party/package.nix b/pkgs/by-name/mi/mihomo-party/package.nix index 9dcf3279ca42..c510a4dd2f8b 100644 --- a/pkgs/by-name/mi/mihomo-party/package.nix +++ b/pkgs/by-name/mi/mihomo-party/package.nix @@ -3,7 +3,6 @@ stdenv, fetchurl, dpkg, - wrapGAppsHook3, autoPatchelfHook, nss, nspr, @@ -43,7 +42,6 @@ stdenv.mkDerivation { nativeBuildInputs = [ dpkg - wrapGAppsHook3 autoPatchelfHook ]; From 2da5248f84020065c1ade1cf3d2342e292fcbcaa Mon Sep 17 00:00:00 2001 From: lyranico Date: Tue, 11 Feb 2025 02:54:42 +0800 Subject: [PATCH 2/3] mihomo-party: use patchelf --- pkgs/by-name/mi/mihomo-party/package.nix | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/pkgs/by-name/mi/mihomo-party/package.nix b/pkgs/by-name/mi/mihomo-party/package.nix index c510a4dd2f8b..b4e8203ed352 100644 --- a/pkgs/by-name/mi/mihomo-party/package.nix +++ b/pkgs/by-name/mi/mihomo-party/package.nix @@ -54,30 +54,27 @@ stdenv.mkDerivation { (lib.getLib stdenv.cc.cc) ]; - runtimeDependencies = map lib.getLib [ - udev - libayatana-appindicator - ]; - installPhase = '' runHook preInstall - mkdir $out + mkdir -p $out/bin cp -r opt/mihomo-party usr/share $out 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 runHook postInstall ''; preFixup = '' - mkdir $out/bin - makeWrapper $out/mihomo-party/mihomo-party $out/bin/mihomo-party \ - --prefix LD_LIBRARY_PATH : "${ + patchelf --add-needed libGL.so.1 \ + --add-rpath ${ lib.makeLibraryPath [ libGL + udev + libayatana-appindicator ] - }" + } $out/mihomo-party/mihomo-party ''; meta = { From 09e97e00caf77f3035bf9d1df2f276a7e5729e4d Mon Sep 17 00:00:00 2001 From: lyranico Date: Tue, 11 Feb 2025 02:58:46 +0800 Subject: [PATCH 3/3] mihomo-party: refactor --- pkgs/by-name/mi/mihomo-party/package.nix | 35 ++++++++++++------------ pkgs/by-name/mi/mihomo-party/update.sh | 2 +- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/pkgs/by-name/mi/mihomo-party/package.nix b/pkgs/by-name/mi/mihomo-party/package.nix index b4e8203ed352..02467ca6ebd1 100644 --- a/pkgs/by-name/mi/mihomo-party/package.nix +++ b/pkgs/by-name/mi/mihomo-party/package.nix @@ -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"; diff --git a/pkgs/by-name/mi/mihomo-party/update.sh b/pkgs/by-name/mi/mihomo-party/update.sh index 380b997c2512..406680fd0208 100755 --- a/pkgs/by-name/mi/mihomo-party/update.sh +++ b/pkgs/by-name/mi/mihomo-party/update.sh @@ -1,5 +1,5 @@ #!/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\(.*\)')"