about summary refs log tree commit diff
path: root/pkgs/misc
diff options
context:
space:
mode:
authorSefa Eyeoglu <contact@scrumplex.net>2023-10-22 17:53:50 +0200
committerYaya <github@uwu.is>2023-10-24 11:21:36 +0200
commitafda2015dcd7f09e53093966293cd72ef64b3a6c (patch)
tree6dbc061cb0d587901bbe1ea4aa863ede73ce8b35 /pkgs/misc
parent587aeb8b1e0a3319188a51ed549da110da1d8376 (diff)
downloadnixlib-afda2015dcd7f09e53093966293cd72ef64b3a6c.tar
nixlib-afda2015dcd7f09e53093966293cd72ef64b3a6c.tar.gz
nixlib-afda2015dcd7f09e53093966293cd72ef64b3a6c.tar.bz2
nixlib-afda2015dcd7f09e53093966293cd72ef64b3a6c.tar.lz
nixlib-afda2015dcd7f09e53093966293cd72ef64b3a6c.tar.xz
nixlib-afda2015dcd7f09e53093966293cd72ef64b3a6c.tar.zst
nixlib-afda2015dcd7f09e53093966293cd72ef64b3a6c.zip
vencord: add update script
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
Diffstat (limited to 'pkgs/misc')
-rw-r--r--pkgs/misc/vencord/default.nix2
-rwxr-xr-xpkgs/misc/vencord/update.sh24
2 files changed, 26 insertions, 0 deletions
diff --git a/pkgs/misc/vencord/default.nix b/pkgs/misc/vencord/default.nix
index 68a5d246f6ed..0fa670faf61e 100644
--- a/pkgs/misc/vencord/default.nix
+++ b/pkgs/misc/vencord/default.nix
@@ -54,6 +54,8 @@ buildNpmPackage rec {
       cp -r dist/ $out
     '';
 
+  passthru.updateScript = ./update.sh;
+
   meta = with lib; {
     description = "Vencord web extension";
     homepage = "https://github.com/Vendicated/Vencord";
diff --git a/pkgs/misc/vencord/update.sh b/pkgs/misc/vencord/update.sh
new file mode 100755
index 000000000000..0317f695f91f
--- /dev/null
+++ b/pkgs/misc/vencord/update.sh
@@ -0,0 +1,24 @@
+#!/usr/bin/env nix-shell
+#! nix-shell -I nixpkgs=../../.. -i bash -p curl jq common-updater-scripts prefetch-npm-deps nodejs
+set -eou pipefail
+
+tempDir=$(mktemp -d)
+
+ghTags=$(curl ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} "https://api.github.com/repos/Vendicated/Vencord/tags")
+latestTag=$(echo "$ghTags" | jq -r .[0].name)
+gitHash=$(echo "$ghTags" | jq -r .[0].commit.sha)
+
+pushd "$tempDir"
+curl "https://raw.githubusercontent.com/Vendicated/Vencord/$latestTag/package.json" -o package.json
+npm install --legacy-peer-deps -f
+
+npmDepsHash=$(prefetch-npm-deps ./package-lock.json)
+popd
+
+pushd ../../..
+update-source-version vencord "${latestTag#v}"
+popd
+
+sed -E 's#\bgitHash = ".*?"#gitHash = "'"${gitHash:0:7}"'"#' -i default.nix
+sed -E 's#\bnpmDepsHash = ".*?"#npmDepsHash = "'"$npmDepsHash"'"#' -i default.nix
+cp "$tempDir/package-lock.json" package-lock.json