diff --git a/pkgs/by-name/we/wechat/darwin.nix b/pkgs/by-name/we/wechat/darwin.nix new file mode 100644 index 0000000000000..e82885d27d6fb --- /dev/null +++ b/pkgs/by-name/we/wechat/darwin.nix @@ -0,0 +1,30 @@ +{ + pname, + version, + src, + meta, + stdenvNoCC, + _7zz, +}: + +stdenvNoCC.mkDerivation { + inherit + pname + version + src + meta + ; + + # dmg is APFS formatted + nativeBuildInputs = [ _7zz ]; + sourceRoot = "."; + + installPhase = '' + runHook preInstall + + mkdir -p $out/Applications + cp -a WeChat.app $out/Applications + + runHook postInstall + ''; +} diff --git a/pkgs/by-name/we/wechat/linux.nix b/pkgs/by-name/we/wechat/linux.nix new file mode 100644 index 0000000000000..0d4f42bf987da --- /dev/null +++ b/pkgs/by-name/we/wechat/linux.nix @@ -0,0 +1,30 @@ +{ + pname, + version, + src, + meta, + appimageTools, +}: + +let + appimageContents = appimageTools.extract { + inherit pname version src; + postExtract = '' + patchelf --replace-needed libtiff.so.5 libtiff.so $out/opt/wechat/wechat + ''; + }; +in +appimageTools.wrapAppImage { + inherit pname version meta; + + src = appimageContents; + + extraInstallCommands = '' + mkdir -p $out/share/applications + cp ${appimageContents}/wechat.desktop $out/share/applications/ + mkdir -p $out/share/pixmaps + cp ${appimageContents}/wechat.png $out/share/pixmaps/ + + substituteInPlace $out/share/applications/wechat.desktop --replace-fail AppRun wechat + ''; +} diff --git a/pkgs/by-name/we/wechat/package.nix b/pkgs/by-name/we/wechat/package.nix index 4824c76ed428e..f3e052d56fa86 100644 --- a/pkgs/by-name/we/wechat/package.nix +++ b/pkgs/by-name/we/wechat/package.nix @@ -1,45 +1,14 @@ { - lib, - appimageTools, + callPackage, fetchurl, + lib, stdenvNoCC, }: let inherit (stdenvNoCC.hostPlatform) system; - pname = "wechat"; - version = "4.0.1.11"; - sources = { - aarch64-linux = fetchurl { - url = "https://web.archive.org/web/20250512112413if_/https://dldir1v6.qq.com/weixin/Universal/Linux/WeChatLinux_arm64.AppImage"; - hash = "sha256-Rg+FWNgOPC02ILUskQqQmlz1qNb9AMdvLcRWv7NQhGk="; - }; - x86_64-linux = fetchurl { - url = "https://web.archive.org/web/20250512110825if_/https://dldir1v6.qq.com/weixin/Universal/Linux/WeChatLinux_x86_64.AppImage"; - hash = "sha256-gBWcNQ1o1AZfNsmu1Vi1Kilqv3YbR+wqOod4XYAeVKo="; - }; - }; - src = appimageTools.extract { - inherit pname version; - src = sources.${system}; - postExtract = '' - patchelf --replace-needed libtiff.so.5 libtiff.so $out/opt/wechat/wechat - ''; - }; -in - -appimageTools.wrapAppImage { - inherit pname version src; - - extraInstallCommands = '' - mkdir -p $out/share/applications - cp ${src}/wechat.desktop $out/share/applications/ - mkdir -p $out/share/pixmaps - cp ${src}/wechat.png $out/share/pixmaps/ - - substituteInPlace $out/share/applications/wechat.desktop --replace-fail AppRun wechat - ''; + pname = "wechat"; meta = { description = "Messaging and calling app"; homepage = "https://www.wechat.com/en/"; @@ -49,8 +18,43 @@ appimageTools.wrapAppImage { maintainers = with lib.maintainers; [ prince213 ]; mainProgram = "wechat"; platforms = [ + "aarch64-darwin" + "x86_64-darwin" "aarch64-linux" "x86_64-linux" ]; }; + + sources = + let + any-darwin = { + version = "4.0.5.24"; + src = fetchurl { + url = "https://web.archive.org/web/20250608064358if_/https://dldir1v6.qq.com/weixin/Universal/Mac/WeChatMac.dmg"; + hash = "sha256-ieixBgYhZ5jU3TWCV7BXKFBidJ1bbabXBHTkrpNcGDI="; + }; + }; + in + { + aarch64-darwin = any-darwin; + x86_64-darwin = any-darwin; + aarch64-linux = { + version = "4.0.1.11"; + src = fetchurl { + url = "https://web.archive.org/web/20250512112413if_/https://dldir1v6.qq.com/weixin/Universal/Linux/WeChatLinux_arm64.AppImage"; + hash = "sha256-Rg+FWNgOPC02ILUskQqQmlz1qNb9AMdvLcRWv7NQhGk="; + }; + }; + x86_64-linux = { + version = "4.0.1.11"; + src = fetchurl { + url = "https://web.archive.org/web/20250512110825if_/https://dldir1v6.qq.com/weixin/Universal/Linux/WeChatLinux_x86_64.AppImage"; + hash = "sha256-gBWcNQ1o1AZfNsmu1Vi1Kilqv3YbR+wqOod4XYAeVKo="; + }; + }; + }; +in +callPackage (if stdenvNoCC.hostPlatform.isDarwin then ./darwin.nix else ./linux.nix) { + inherit pname meta; + inherit (sources.${system} or (throw "Unsupported system: ${system}")) version src; }