about summary refs log tree commit diff
path: root/pkgs/os-specific/darwin
diff options
context:
space:
mode:
authorDontEatOreo <57304299+DontEatOreo@users.noreply.github.com>2024-04-03 20:06:59 +0300
committerDontEatOreo <57304299+DontEatOreo@users.noreply.github.com>2024-04-03 22:25:28 +0300
commit36cac1a5f09457ce7c52c24bfe1dd96f962950ad (patch)
treee43321fe1263dd9d3c9266867966e8d2ff63db5d /pkgs/os-specific/darwin
parent394a44ced3f7879d276a76791cce485e248494ee (diff)
raycast: add passthru.updateScript
Diffstat (limited to 'pkgs/os-specific/darwin')
-rw-r--r--pkgs/os-specific/darwin/raycast/default.nix17
-rwxr-xr-xpkgs/os-specific/darwin/raycast/update.sh20
2 files changed, 17 insertions, 20 deletions
diff --git a/pkgs/os-specific/darwin/raycast/default.nix b/pkgs/os-specific/darwin/raycast/default.nix
index 59c60b320f689..e9d75a5ad1447 100644
--- a/pkgs/os-specific/darwin/raycast/default.nix
+++ b/pkgs/os-specific/darwin/raycast/default.nix
@@ -1,6 +1,10 @@
 { lib
 , stdenvNoCC
 , fetchurl
+, writeShellApplication
+, curl
+, jq
+, common-updater-scripts
 , undmg
 }:
 
@@ -32,6 +36,19 @@ stdenvNoCC.mkDerivation (finalAttrs: {
     runHook postInstall
   '';
 
+  passthru = {
+    updateScript = writeShellApplication {
+      name = "raycast-update-script";
+      runtimeInputs = [ curl jq common-updater-scripts ];
+      text = ''
+        set -eo pipefail
+        url=$(curl --silent "https://releases.raycast.com/releases/latest?build=universal")
+        version=$(echo "$url" | jq -r '.version')
+        update-source-version raycast "$version" --file=./pkgs/os-specific/darwin/raycast/default.nix
+      '';
+    };
+  };
+
   meta = with lib; {
     description = "Control your tools with a few keystrokes";
     homepage = "https://raycast.app/";
diff --git a/pkgs/os-specific/darwin/raycast/update.sh b/pkgs/os-specific/darwin/raycast/update.sh
deleted file mode 100755
index e33f8421597d9..0000000000000
--- a/pkgs/os-specific/darwin/raycast/update.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/env nix-shell
-#!nix-shell -I nixpkgs=../../../../. -i bash -p common-updater-scripts jq
-
-set -eo pipefail
-
-new_version=$(curl --silent https://releases.raycast.com/releases/latest?build=universal | jq -r '.version')
-old_version=$(sed -nE 's/\s*version = "(.*)".*/\1/p' ./default.nix)
-
-if [[ $new_version == $old_version ]]; then
-    echo "Already up to date."
-    exit 0
-else
-    echo "raycast: $old_version -> $new_version"
-    sed -Ei.bak '/ *version = "/s/".+"/"'"$new_version"'"/' ./default.nix
-    rm ./default.nix.bak
-fi
-
-hash=$(nix --extra-experimental-features nix-command store prefetch-file --json --hash-type sha256 "https://releases.raycast.com/releases/$new_version/download?build=universal" | jq -r '.hash')
-sed -Ei.bak '/ *hash = /{N;N; s@("sha256-)[^;"]+@"'"$hash"'@}' ./default.nix
-rm ./default.nix.bak