onefetch: 2.22.0 -> 2.23.1 (#370530)
[NixPkgs.git] / pkgs / by-name / wh / whatsapp-for-mac / package.nix
blobba3966fd557e919d77d0fedfcd34fd819c4c8cf0
1 { lib
2 , fetchzip
3 , stdenvNoCC
4 , writeShellApplication
5 , curl
6 , xmlstarlet
7 , common-updater-scripts
8 }:
10 stdenvNoCC.mkDerivation (finalAttrs: {
11   pname = "whatsapp-for-mac";
12   version = "2.24.23.82";
14   src = fetchzip {
15     extension = "zip";
16     name = "WhatsApp.app";
17     url = "https://web.whatsapp.com/desktop/mac_native/release/?version=${finalAttrs.version}&extension=zip&configuration=Release&branch=relbranch";
18     hash = "sha256-FnXW3l4JUdJkDQ7eASlDeUzRdZ2N5l3WvEKcuBuE0nY=";
19   };
21   dontConfigure = true;
22   dontBuild = true;
24   sourceRoot = ".";
26   installPhase = ''
27     runHook preInstall
29     mkdir -p "$out/Applications"
30     cp -r *.app "$out/Applications"
32     runHook postInstall
33   '';
35   passthru.updateScript = lib.getExe (writeShellApplication {
36     name = "whatsapp-update-script";
37     runtimeInputs = [
38       curl
39       xmlstarlet
40       common-updater-scripts
41     ];
42     text = ''
43       url=$(curl --silent "https://web.whatsapp.com/desktop/mac_native/updates/?branch=relbranch&configuration=Release")
44       version=$(echo "$url" | xmlstarlet sel -t -v "substring-before(substring-after(//enclosure/@url, 'version='), '&')")
45       update-source-version whatsapp-for-mac "$version" --file=./pkgs/by-name/wh/whatsapp-for-mac/package.nix
46     '';
47   });
49   meta = {
50     description = "Native desktop client for WhatsApp";
51     homepage = "https://www.whatsapp.com/";
52     license = lib.licenses.unfree;
53     maintainers = with lib.maintainers; [ iivusly ];
54     platforms = lib.platforms.darwin;
55     sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
56   };