diff --git a/pkgs/by-name/qq/qq/package.nix b/pkgs/by-name/qq/qq/package.nix index 9728db8584d3..fb48240150e5 100644 --- a/pkgs/by-name/qq/qq/package.nix +++ b/pkgs/by-name/qq/qq/package.nix @@ -20,6 +20,7 @@ xorg, systemd, stdenv, + undmg, vips, at-spi2-core, autoPatchelfHook, @@ -33,87 +34,19 @@ let source = sources.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); -in -stdenv.mkDerivation { pname = "qq"; inherit (source) version src; - - nativeBuildInputs = [ - autoPatchelfHook - makeShellWrapper - wrapGAppsHook3 - dpkg - ]; - - buildInputs = [ - alsa-lib - at-spi2-core - cups - glib - gtk3 - libdrm - libpulseaudio - libgcrypt - libkrb5 - libgbm - nss - vips - xorg.libXdamage - ]; - - dontWrapGApps = true; - - runtimeDependencies = map lib.getLib [ - systemd - libkrb5 - ]; - - installPhase = '' - runHook preInstall - - mkdir -p $out/bin - cp -r opt $out/opt - cp -r usr/share $out/share - substituteInPlace $out/share/applications/qq.desktop \ - --replace-fail "/opt/QQ/qq" "$out/bin/qq" \ - --replace-fail "/usr/share" "$out/share" - makeShellWrapper $out/opt/QQ/qq $out/bin/qq \ - --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH" \ - --prefix LD_PRELOAD : "${lib.makeLibraryPath [ libssh2 ]}/libssh2.so.1" \ - --prefix LD_LIBRARY_PATH : "${ - lib.makeLibraryPath [ - libGL - libuuid - ] - }" \ - --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \ - --add-flags ${lib.escapeShellArg commandLineArgs} \ - "''${gappsWrapperArgs[@]}" - - # Remove bundled libraries - rm -r $out/opt/QQ/resources/app/sharp-lib - - # https://aur.archlinux.org/cgit/aur.git/commit/?h=linuxqq&id=f7644776ee62fa20e5eb30d0b1ba832513c77793 - rm -r $out/opt/QQ/resources/app/libssh2.so.1 - - # https://github.com/microcai/gentoo-zh/commit/06ad5e702327adfe5604c276635ae8a373f7d29e - ln -s ${libayatana-appindicator}/lib/libayatana-appindicator3.so \ - $out/opt/QQ/libappindicator3.so - - ln -s ${libnotify}/lib/libnotify.so \ - $out/opt/QQ/libnotify.so - - runHook postInstall - ''; - - passthru.updateScript = ./update.sh; - + passthru = { + updateScript = ./update.sh; + }; meta = { - homepage = "https://im.qq.com/linuxqq/"; + homepage = "https://im.qq.com/index/"; description = "Messaging app"; platforms = [ - "x86_64-linux" + "aarch64-darwin" "aarch64-linux" + "x86_64-darwin" + "x86_64-linux" ]; license = lib.licenses.unfree; sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; @@ -123,4 +56,104 @@ stdenv.mkDerivation { prince213 ]; }; -} +in +if stdenv.hostPlatform.isDarwin then + stdenv.mkDerivation { + inherit + pname + version + src + passthru + meta + ; + + nativeBuildInputs = [ undmg ]; + sourceRoot = "."; + + installPhase = '' + runHook preInstall + + mkdir -p $out/Applications + cp -a QQ.app $out/Applications + + runHook postInstall + ''; + } +else + stdenv.mkDerivation { + inherit + pname + version + src + passthru + meta + ; + + nativeBuildInputs = [ + autoPatchelfHook + makeShellWrapper + wrapGAppsHook3 + dpkg + ]; + + buildInputs = [ + alsa-lib + at-spi2-core + cups + glib + gtk3 + libdrm + libpulseaudio + libgcrypt + libkrb5 + libgbm + nss + vips + xorg.libXdamage + ]; + + dontWrapGApps = true; + + runtimeDependencies = map lib.getLib [ + systemd + libkrb5 + ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/bin + cp -r opt $out/opt + cp -r usr/share $out/share + substituteInPlace $out/share/applications/qq.desktop \ + --replace-fail "/opt/QQ/qq" "$out/bin/qq" \ + --replace-fail "/usr/share" "$out/share" + makeShellWrapper $out/opt/QQ/qq $out/bin/qq \ + --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH" \ + --prefix LD_PRELOAD : "${lib.makeLibraryPath [ libssh2 ]}/libssh2.so.1" \ + --prefix LD_LIBRARY_PATH : "${ + lib.makeLibraryPath [ + libGL + libuuid + ] + }" \ + --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \ + --add-flags ${lib.escapeShellArg commandLineArgs} \ + "''${gappsWrapperArgs[@]}" + + # Remove bundled libraries + rm -r $out/opt/QQ/resources/app/sharp-lib + + # https://aur.archlinux.org/cgit/aur.git/commit/?h=linuxqq&id=f7644776ee62fa20e5eb30d0b1ba832513c77793 + rm -r $out/opt/QQ/resources/app/libssh2.so.1 + + # https://github.com/microcai/gentoo-zh/commit/06ad5e702327adfe5604c276635ae8a373f7d29e + ln -s ${libayatana-appindicator}/lib/libayatana-appindicator3.so \ + $out/opt/QQ/libappindicator3.so + + ln -s ${libnotify}/lib/libnotify.so \ + $out/opt/QQ/libnotify.so + + runHook postInstall + ''; + } diff --git a/pkgs/by-name/qq/qq/sources.nix b/pkgs/by-name/qq/qq/sources.nix index 43684d278684..6b16cd97f70c 100644 --- a/pkgs/by-name/qq/qq/sources.nix +++ b/pkgs/by-name/qq/qq/sources.nix @@ -1,7 +1,18 @@ # Generated by ./update.sh - do not update manually! # Last updated: 2025-06-17 { fetchurl }: +let + any-darwin = { + version = "6.9.75-2025.6.16"; + src = fetchurl { + url = "https://dldir1v6.qq.com/qqfile/qq/QQNT/Mac/QQ_6.9.75_250616_01.dmg"; + hash = "sha256-MS2WGrAuBGlbzzxfUlcixoD1snchEaLu4Ecvt84Hdfo="; + }; + }; +in { + aarch64-darwin = any-darwin; + x86_64-darwin = any-darwin; aarch64-linux = { version = "3.2.18-2025.6.16"; src = fetchurl { diff --git a/pkgs/by-name/qq/qq/update.sh b/pkgs/by-name/qq/qq/update.sh index 12304716f632..e281dbf08b72 100755 --- a/pkgs/by-name/qq/qq/update.sh +++ b/pkgs/by-name/qq/qq/update.sh @@ -5,6 +5,19 @@ set -euo pipefail cd $(readlink -e $(dirname "${BASH_SOURCE[0]}")) +# darwin + +darwin_url=$(curl -s https://im.qq.com/macqq/index.shtml | grep -oP 'var rainbowConfigUrl = "\K.*(?=";)') +darwin_payload=$(curl "$darwin_url" | grep -oP "var params= \K\{.*\}(?=;)") +darwin_version=$(jq -r .version <<< "$darwin_payload" | awk -F\ '{print $1}')-$(jq -r .updateDate <<< "$darwin_payload") + +darwin_url=$(jq -r .downloadUrl <<< "$darwin_payload") + +darwin_hash=$(nix-prefetch-url $darwin_url) + +# use friendlier hashes +darwin_hash=$(nix hash convert --to sri --hash-algo sha256 "$darwin_hash") + # linux linux_url=$(curl -s https://im.qq.com/linuxqq/index.shtml | grep -oP 'var rainbowConfigUrl = "\K.*(?=";)') @@ -25,7 +38,18 @@ cat >sources.nix <