about summary refs log tree commit diff
path: root/pkgs/data/misc/mailcap
diff options
context:
space:
mode:
authorMartin Weinelt2024-06-07 16:18:27 +0200
committerMartin Weinelt2024-06-07 16:18:27 +0200
commitf44584d4dedc7f7a83318aa68f3a5a2dd37a0235 (patch)
tree6062e9a398dee3b269cac76a5381a4440f26d1b2 /pkgs/data/misc/mailcap
parentbdb5db0942bc37bd2e6423c9cd95a738ad519843 (diff)
mailcap: add update script
Diffstat (limited to 'pkgs/data/misc/mailcap')
-rw-r--r--pkgs/data/misc/mailcap/default.nix24
1 files changed, 23 insertions, 1 deletions
diff --git a/pkgs/data/misc/mailcap/default.nix b/pkgs/data/misc/mailcap/default.nix
index e2270d76bbab..b3560ecc505c 100644
--- a/pkgs/data/misc/mailcap/default.nix
+++ b/pkgs/data/misc/mailcap/default.nix
@@ -1,4 +1,15 @@
-{ lib, stdenv, fetchurl }:
+{ lib
+, stdenv
+, fetchurl
+
+# updater
+, git
+, coreutils
+, gawk
+, gnused
+, writeScript
+, nix-update
+}:
 
 stdenv.mkDerivation rec {
   pname = "mailcap";
@@ -22,6 +33,17 @@ stdenv.mkDerivation rec {
     runHook postInstall
   '';
 
+  passthru.updateScript = writeScript "update-mailcap" ''
+    export PATH=${lib.makeBinPath [ git coreutils gawk gnused nix-update ]}:$PATH
+    VERSION="$(git ls-remote --tags --sort="v:refname" https://pagure.io/mailcap.git | \
+      awk '{ print $2 }' | \
+      grep "refs/tags/r" | \
+      sed -E -e "s,refs/tags/r(.*)$,\1," -e "s/-/./g" | \
+      sort --version-sort --reverse | \
+      head -n1)"
+    exec nix-update --version "$VERSION" "$@"
+  '';
+
   meta = with lib; {
     description = "Helper application and MIME type associations for file types";
     homepage = "https://pagure.io/mailcap";