nixos/tests/userborn: fix setting hostPlatform (#378940)
[NixPkgs.git] / pkgs / by-name / ra / raycast / package.nix
blobcb38a35d6831e9574d40f2ddc8053f142e3703bb
2   lib,
3   stdenvNoCC,
4   fetchurl,
5   writeShellApplication,
6   cacert,
7   curl,
8   jq,
9   openssl,
10   undmg,
13 stdenvNoCC.mkDerivation (finalAttrs: {
14   pname = "raycast";
15   version = "1.90.0";
17   src =
18     {
19       aarch64-darwin = fetchurl {
20         name = "Raycast.dmg";
21         url = "https://releases.raycast.com/releases/${finalAttrs.version}/download?build=arm";
22         hash = "sha256-3++hipn/7dJKQhY1gh8v/OsY+R316n5EJcEcmOheYnM=";
23       };
24       x86_64-darwin = fetchurl {
25         name = "Raycast.dmg";
26         url = "https://releases.raycast.com/releases/${finalAttrs.version}/download?build=x86_64";
27         hash = "sha256-qa4ESWW6voh45Kl0ydL6kyTwH8MNUNnyRSlFJcu3trI=";
28       };
29     }
30     .${stdenvNoCC.system} or (throw "raycast: ${stdenvNoCC.system} is unsupported.");
32   dontPatch = true;
33   dontConfigure = true;
34   dontBuild = true;
35   dontFixup = true;
37   nativeBuildInputs = [ undmg ];
39   sourceRoot = "Raycast.app";
41   installPhase = ''
42     runHook preInstall
44     mkdir -p $out/Applications/Raycast.app
45     cp -R . $out/Applications/Raycast.app
47     runHook postInstall
48   '';
50   passthru.updateScript = lib.getExe (writeShellApplication {
51     name = "raycast-update-script";
52     runtimeInputs = [
53       cacert
54       curl
55       jq
56       openssl
57     ];
58     text = ''
59       url=$(curl --silent "https://releases.raycast.com/releases/latest?build=universal")
60       version=$(echo "$url" | jq -r '.version')
62       arm_url="https://releases.raycast.com/releases/$version/download?build=arm"
63       x86_url="https://releases.raycast.com/releases/$version/download?build=x86_64"
65       arm_hash="sha256-$(curl -sL "$arm_url" | openssl dgst -sha256 -binary | openssl base64)"
66       x86_hash="sha256-$(curl -sL "$x86_url" | openssl dgst -sha256 -binary | openssl base64)"
68       sed -i -E \
69         -e 's|(version = )"[0-9]+\.[0-9]+\.[0-9]+";|\1"'"$version"'";|' \
70         -e '/aarch64-darwin = fetchurl/,/};/ s|(hash = )"sha256-[A-Za-z0-9+/]+=";|\1"'"$arm_hash"'";|' \
71         -e '/x86_64-darwin = fetchurl/,/};/ s|(hash = )"sha256-[A-Za-z0-9+/]+=";|\1"'"$x86_hash"'";|' \
72         ./pkgs/by-name/ra/raycast/package.nix
73     '';
74   });
76   meta = {
77     description = "Control your tools with a few keystrokes";
78     homepage = "https://raycast.app/";
79     license = lib.licenses.unfree;
80     maintainers = with lib.maintainers; [
81       lovesegfault
82       stepbrobd
83       donteatoreo
84       jakecleary
85     ];
86     platforms = [
87       "aarch64-darwin"
88       "x86_64-darwin"
89     ];
90     sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
91   };