about summary refs log tree commit diff
path: root/pkgs/applications/networking/browsers/palemoon
diff options
context:
space:
mode:
authorOPNA2608 <opna2608@protonmail.com>2024-04-15 15:02:12 +0200
committerOPNA2608 <opna2608@protonmail.com>2024-04-15 15:02:12 +0200
commit35aa61baf1671b8aabf95cfe222d9f7040a8192c (patch)
treecd6949fb2eaca46c8662fd55e41df5e05087454c /pkgs/applications/networking/browsers/palemoon
parent26594c44f5811a0e924b808b16e01dcf14050a6c (diff)
palemoon-bin: Add meta.updateScript
Diffstat (limited to 'pkgs/applications/networking/browsers/palemoon')
-rw-r--r--pkgs/applications/networking/browsers/palemoon/bin.nix57
1 files changed, 45 insertions, 12 deletions
diff --git a/pkgs/applications/networking/browsers/palemoon/bin.nix b/pkgs/applications/networking/browsers/palemoon/bin.nix
index bc4235d82795b..1e993ddbb5b51 100644
--- a/pkgs/applications/networking/browsers/palemoon/bin.nix
+++ b/pkgs/applications/networking/browsers/palemoon/bin.nix
@@ -14,6 +14,7 @@
 , libpulseaudio
 , makeDesktopItem
 , wrapGAppsHook
+, writeScript
 , testers
 }:
 
@@ -21,16 +22,7 @@ stdenv.mkDerivation (finalAttrs: {
   pname = "palemoon-bin";
   version = "33.0.0";
 
-  src = fetchzip {
-    urls = [
-      "https://rm-eu.palemoon.org/release/palemoon-${finalAttrs.version}.linux-x86_64-gtk${if withGTK3 then "3" else "2"}.tar.xz"
-      "https://rm-us.palemoon.org/release/palemoon-${finalAttrs.version}.linux-x86_64-gtk${if withGTK3 then "3" else "2"}.tar.xz"
-    ];
-    hash = if withGTK3 then
-      "sha256-qZX23dsKNg5AOIaBAAmTWT6VDEl3OGz3kb3idtvJElw="
-    else
-      "sha256-Lz1+5I8Rj0GrBUBTJoRsatpyzkqVHZuWbKARkuWFs5U=";
-  };
+  src = finalAttrs.passthru.sources."gtk${if withGTK3 then "3" else "2"}";
 
   preferLocalBuild = true;
 
@@ -155,8 +147,49 @@ stdenv.mkDerivation (finalAttrs: {
     wrapGApp $out/lib/palemoon/palemoon
   '';
 
-  passthru.tests.version = testers.testVersion {
-    package = finalAttrs.finalPackage;
+  passthru = {
+    sources = let
+      urlRegionVariants = buildVariant: map
+        (region: "https://rm-${region}.palemoon.org/release/palemoon-${finalAttrs.version}.linux-x86_64-${buildVariant}.tar.xz")
+        [
+          "eu"
+          "us"
+        ];
+    in {
+      gtk3 = fetchzip {
+        urls = urlRegionVariants "gtk3";
+        hash = "sha256-qZX23dsKNg5AOIaBAAmTWT6VDEl3OGz3kb3idtvJElw=";
+      };
+      gtk2 = fetchzip {
+        urls = urlRegionVariants "gtk2";
+        hash = "sha256-Lz1+5I8Rj0GrBUBTJoRsatpyzkqVHZuWbKARkuWFs5U=";
+      };
+    };
+
+    tests.version = testers.testVersion {
+      package = finalAttrs.finalPackage;
+    };
+
+    updateScript = writeScript "update-palemoon-bin" ''
+      #!/usr/bin/env nix-shell
+      #!nix-shell -i bash -p common-updater-scripts curl libxml2
+
+      set -eu -o pipefail
+
+      # Only release note announcement == finalized release
+      version="$(
+        curl -s 'http://www.palemoon.org/releasenotes.shtml' |
+        xmllint --html --xpath 'html/body/table/tbody/tr/td/h3/text()' - 2>/dev/null | head -n1 |
+        sed 's/v\(\S*\).*/\1/'
+      )"
+
+      for variant in gtk3 gtk2; do
+        # The script will not perform an update when the version attribute is up to date from previous platform run
+        # We need to clear it before each run
+        update-source-version palemoon-bin 0 "${lib.fakeHash}" --source-key="sources.$variant"
+        update-source-version palemoon-bin "$version" --source-key="sources.$variant"
+      done
+    '';
   };
 
   meta = with lib; {