From 18797d74ac8b5b00d7042c1828efafdece368e80 Mon Sep 17 00:00:00 2001
From: Julien Moutinho <julm+sourcephile-nix@sourcephile.fr>
Date: Sun, 21 Nov 2021 08:49:33 +0100
Subject: [PATCH] sourcehut: update patch from nixpkgs#133984

---
 nixpkgs/patches/sourcehut.diff | 79 +++++++++++++++++-----------------
 1 file changed, 40 insertions(+), 39 deletions(-)

diff --git a/nixpkgs/patches/sourcehut.diff b/nixpkgs/patches/sourcehut.diff
index 8711e51..6288033 100644
--- a/nixpkgs/patches/sourcehut.diff
+++ b/nixpkgs/patches/sourcehut.diff
@@ -4385,7 +4385,7 @@ index b56a14ebf85..6492250bd57 100644
    };
  
 diff --git a/pkgs/applications/version-management/sourcehut/builds.nix b/pkgs/applications/version-management/sourcehut/builds.nix
-index c8163caf8ea..99f3946253b 100644
+index c8163caf8ea..55d09ad0d34 100644
 --- a/pkgs/applications/version-management/sourcehut/builds.nix
 +++ b/pkgs/applications/version-management/sourcehut/builds.nix
 @@ -11,26 +11,54 @@
@@ -4404,14 +4404,14 @@ index c8163caf8ea..99f3946253b 100644
 -buildPythonPackage rec {
 -  inherit version;
 -  pname = "buildsrht";
-+  version = "0.73.3";
++  version = "0.74.2";
  
    src = fetchFromSourcehut {
      owner = "~sircmpwn";
      repo = "builds.sr.ht";
      rev = version;
 -    sha256 = "sha256-2MLs/DOXHjEYarXDVUcPZe3o0fmZbzVxn528SE72lhM=";
-+    sha256 = "sha256-/0KYQgl/pfZomD1EEF9iI9HnNR99a8OB3/n5IfgClQk=";
++    sha256 = "sha256-vdVKaI42pA0dnyMXhQ4AEaDgTtKcrH6hc9L6PFcl6ZA=";
    };
  
 +  worker = buildGoModule {
@@ -4477,7 +4477,7 @@ index c8163caf8ea..99f3946253b 100644
    };
  }
 diff --git a/pkgs/applications/version-management/sourcehut/core.nix b/pkgs/applications/version-management/sourcehut/core.nix
-index 7c3a516ed9d..0c2dec45b99 100644
+index 7c3a516ed9d..7e7aca4df2d 100644
 --- a/pkgs/applications/version-management/sourcehut/core.nix
 +++ b/pkgs/applications/version-management/sourcehut/core.nix
 @@ -25,17 +25,16 @@
@@ -4490,13 +4490,13 @@ index 7c3a516ed9d..0c2dec45b99 100644
  buildPythonPackage rec {
    pname = "srht";
 -  version = "0.67.4";
-+  version = "0.68.1";
++  version = "0.68.2";
  
    src = fetchgit {
      url = "https://git.sr.ht/~sircmpwn/core.sr.ht";
      rev = version;
 -    sha256 = "sha256-XvzFfcBK5Mq8p7xEBAF/eupUE1kkUBh5k+ByM/WA9bc=";
-+    sha256 = "sha256-gfJB3zTzs2Uj5EREWV8a5ftt4uNCkuYsGnvTXWImitc=";
++    sha256 = "sha256-vLdKJgi3arF5PSODbCSCX7fWGZfgkOirGSdYzcNXRdk=";
      fetchSubmodules = true;
    };
  
@@ -4581,7 +4581,7 @@ index 637c6f9c1df..9456d0c998c 100644
    };
  }
 diff --git a/pkgs/applications/version-management/sourcehut/git.nix b/pkgs/applications/version-management/sourcehut/git.nix
-index e44fb9cd6c6..32c719bbc24 100644
+index e44fb9cd6c6..21898faf857 100644
 --- a/pkgs/applications/version-management/sourcehut/git.nix
 +++ b/pkgs/applications/version-management/sourcehut/git.nix
 @@ -6,42 +6,109 @@
@@ -4592,14 +4592,14 @@ index e44fb9cd6c6..32c719bbc24 100644
  }:
  let
 -  version = "0.72.8";
-+  version = "0.73.4";
++  version = "0.73.6";
  
    src = fetchFromSourcehut {
      owner = "~sircmpwn";
      repo = "git.sr.ht";
      rev = version;
 -    sha256 = "sha256-AB2uzajO5PtcpJfbOOTfuDFM6is5K39v3AZJ1hShRNc=";
-+    sha256 = "sha256-MxmMneK5RKA9EQMHGGUjmjQUybHV3xaxFetzlaLAf+E=";
++    sha256 = "sha256-9WdeHXmyX5K/ldaE9AbSWTRlsrSDuKtm8QhthEHfmuU=";
    };
  
 -  buildShell = src: buildGoModule {
@@ -4638,7 +4638,7 @@ index e44fb9cd6c6..32c719bbc24 100644
 +    # to changes from upstream, and thus harder to maintain the patching
 +    # while it hasn't been merged upstream.
 +
-+    overrideModAttrs = old: {
++    overrideModAttrs = _: {
 +      preBuild = ''
 +        # This is a fixed-output derivation so it is not allowed to reference other derivations,
 +        # but here srht-keys will be copied to vendor/ by go mod vendor
@@ -4671,7 +4671,7 @@ index e44fb9cd6c6..32c719bbc24 100644
      pname = "gitsrht-update-hook";
 -    vendorSha256 = "0fwzqpjv8x5y3w3bfjd0x0cvqjjak23m0zj88hf32jpw49xmjkih";
 -  };
-+    vendorSha256 = "sha256-QWd4i9qnnKbgO4qdFwZI3wlcsSurCh2ydhLYEyEZyK8=";
++    vendorSha256 = "sha256-L/tGwbBSwhtGhHcinCK/0lsp1ffXjiHXCmGgsY9s2Nc=";
  
 -  updateHook = buildUpdateHook "${src}/gitsrht-update-hook";
 +    # What follows is only to update go-redis
@@ -4734,7 +4734,7 @@ index e44fb9cd6c6..32c719bbc24 100644
    };
  }
 diff --git a/pkgs/applications/version-management/sourcehut/hg.nix b/pkgs/applications/version-management/sourcehut/hg.nix
-index cddb76cabf2..1d6062d81cc 100644
+index cddb76cabf2..e13b27d4139 100644
 --- a/pkgs/applications/version-management/sourcehut/hg.nix
 +++ b/pkgs/applications/version-management/sourcehut/hg.nix
 @@ -10,12 +10,12 @@
@@ -4742,13 +4742,13 @@ index cddb76cabf2..1d6062d81cc 100644
  buildPythonPackage rec {
    pname = "hgsrht";
 -  version = "0.27.4";
-+  version = "0.27.6";
++  version = "0.28.1";
  
    src = fetchhg {
      url = "https://hg.sr.ht/~sircmpwn/hg.sr.ht";
      rev = version;
 -    sha256 = "1c0qfi0gmbfngvds6917fy9ii2iglawn429757rh7b4bvzn7n6mr";
-+    sha256 = "ibijvKjS4CiWTYrO6Qdh3RkD0EUE7BY8wjdPwrD6vkA=";
++    sha256 = "ERMPaCtExZebwV1BrjyE/gGK7p/Nvf7ia+ZBO472bdw=";
    };
  
    nativeBuildInputs = srht.nativeBuildInputs;
@@ -4767,7 +4767,7 @@ index cddb76cabf2..1d6062d81cc 100644
    };
  }
 diff --git a/pkgs/applications/version-management/sourcehut/hub.nix b/pkgs/applications/version-management/sourcehut/hub.nix
-index 17cb3fe4b61..bf056190e04 100644
+index 17cb3fe4b61..9c834246def 100644
 --- a/pkgs/applications/version-management/sourcehut/hub.nix
 +++ b/pkgs/applications/version-management/sourcehut/hub.nix
 @@ -6,13 +6,13 @@
@@ -4775,14 +4775,14 @@ index 17cb3fe4b61..bf056190e04 100644
  buildPythonPackage rec {
    pname = "hubsrht";
 -  version = "0.13.1";
-+  version = "0.13.15";
++  version = "0.13.16";
  
    src = fetchFromSourcehut {
      owner = "~sircmpwn";
      repo = "hub.sr.ht";
      rev = version;
 -    sha256 = "sha256-Kqzy4mh5Nn1emzHBco/LVuXro/tW3NX+OYqdEwBSQ/U=";
-+    sha256 = "sha256-B0GdplnLxk18sHwOow7kLCTjoyyLKushCQumuYfuRMQ=";
++    sha256 = "sha256-TyeEJvkRjqTs92+pKloJhpTnnkYaMZHZkdO6Da5Bq7c=";
    };
  
    nativeBuildInputs = srht.nativeBuildInputs;
@@ -4869,7 +4869,7 @@ index bd331f000a7..2d4d152e3aa 100644
    };
  }
 diff --git a/pkgs/applications/version-management/sourcehut/meta.nix b/pkgs/applications/version-management/sourcehut/meta.nix
-index 86d293973d7..5789b0c6127 100644
+index 86d293973d7..96ea83a4ef3 100644
 --- a/pkgs/applications/version-management/sourcehut/meta.nix
 +++ b/pkgs/applications/version-management/sourcehut/meta.nix
 @@ -18,19 +18,19 @@
@@ -4877,14 +4877,14 @@ index 86d293973d7..5789b0c6127 100644
  }:
  let
 -  version = "0.53.14";
-+  version = "0.56.18";
++  version = "0.56.19";
  
    src = fetchFromSourcehut {
      owner = "~sircmpwn";
      repo = "meta.sr.ht";
      rev = version;
 -    sha256 = "sha256-/+r/XLDkcSTW647xPMh5bcJmR2xZNNH74AJ5jemna2k=";
-+    sha256 = "sha256-jt5UecpQORDr82HHDe7JBJ4ofnAYJl5Bnd7pRdVYnYM=";
++    sha256 = "sha256-YVj+aehO+2cJGvti9KXexm3y/0dx3rZBjEf0tKFC+s4=";
    };
  
    buildApi = src: buildGoModule {
@@ -4911,28 +4911,26 @@ index 86d293973d7..5789b0c6127 100644
  }
 diff --git a/pkgs/applications/version-management/sourcehut/pages.nix b/pkgs/applications/version-management/sourcehut/pages.nix
 new file mode 100644
-index 00000000000..ab2126ea5db
+index 00000000000..c49e49c2664
 --- /dev/null
 +++ b/pkgs/applications/version-management/sourcehut/pages.nix
-@@ -0,0 +1,32 @@
+@@ -0,0 +1,30 @@
 +{ lib
 +, fetchFromSourcehut
 +, buildGoModule
 +}:
-+let
-+  version = "0.5.0";
++
++buildGoModule rec {
++  pname = "pagessrht";
++  version = "0.5.1";
 +
 +  src = fetchFromSourcehut {
 +    owner = "~sircmpwn";
 +    repo = "pages.sr.ht";
 +    rev = version;
-+    sha256 = "sha256-SwKiNqsPbUgJyj8qSY1c7dwDiEMznEWmFun57YmDRKw=";
++    sha256 = "sha256-Cab8zx+9WHHAB1rBoyZACq7lx9JdRBGzI1H+Yu9qHfs=";
 +  };
 +
-+in
-+buildGoModule {
-+  inherit src version;
-+  pname = "pagessrht";
 +  vendorSha256 = "sha256-udr+1y5ApQCSPhs3yQTTi9QfzRbz0A9COYuFMjQGa74=";
 +
 +  postInstall = ''
@@ -5963,7 +5961,7 @@ index 00000000000..c5407a26491
 +2.32.0
 +
 diff --git a/pkgs/applications/version-management/sourcehut/scm.nix b/pkgs/applications/version-management/sourcehut/scm.nix
-index 1f385265360..828bc1f8032 100644
+index 1f385265360..55bc2aa9e72 100644
 --- a/pkgs/applications/version-management/sourcehut/scm.nix
 +++ b/pkgs/applications/version-management/sourcehut/scm.nix
 @@ -1,22 +1,57 @@
@@ -5982,14 +5980,14 @@ index 1f385265360..828bc1f8032 100644
  buildPythonPackage rec {
    pname = "scmsrht";
 -  version = "0.22.9";
-+  version = "0.22.13";
++  version = "0.22.15";
  
    src = fetchFromSourcehut {
      owner = "~sircmpwn";
      repo = "scm.sr.ht";
      rev = version;
 -    sha256 = "sha256-327G6C8FW+iZx+167D7TQsFtV6FGc8MpMVo9L/cUUqU=";
-+    sha256 = "sha256-9iRmQBt4Cxr5itTk34b8iDRyXYDHTDfZjV0SIDT/kkM=";
++    sha256 = "sha256-h4akgDn78ctBF31TX8D8NwUVUVazClPVvCR9xWyQPBk=";
 +  };
 +
 +  passthru = {
@@ -6085,13 +6083,13 @@ index 85e1f5637b6..cdb1f8cf8be 100644
    };
  }
 diff --git a/pkgs/applications/version-management/sourcehut/update.sh b/pkgs/applications/version-management/sourcehut/update.sh
-index 156d4cc35e4..fb78d39ec40 100755
+index 156d4cc35e4..1638313697c 100755
 --- a/pkgs/applications/version-management/sourcehut/update.sh
 +++ b/pkgs/applications/version-management/sourcehut/update.sh
 @@ -1,8 +1,11 @@
  #! /usr/bin/env nix-shell
  #! nix-shell -i bash -p git mercurial common-updater-scripts
-+set -x
++set -eux -o pipefail
  
 -cd "$(dirname "${BASH_SOURCE[0]}")"
 +cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1
@@ -6101,7 +6099,7 @@ index 156d4cc35e4..fb78d39ec40 100755
  
  default() {
    (cd "$root" && nix-instantiate --eval --strict -A "sourcehut.python.pkgs.$1.meta.position" | sed -re 's/^"(.*):[0-9]+"$/\1/')
-@@ -13,42 +16,59 @@ version() {
+@@ -13,42 +16,61 @@ version() {
  }
  
  src_url() {
@@ -6134,6 +6132,8 @@ index 156d4cc35e4..fb78d39ec40 100755
  
    (cd "$root" && update-source-version "sourcehut.python.pkgs.$1" "$version")
  
+-  git add "$default_nix"
+-  git commit -m "$1: $version_old -> $version"
 +  # Update vendorSha256 of Go modules
 +  retry=true
 +  while "$retry"; do
@@ -6142,15 +6142,16 @@ index 156d4cc35e4..fb78d39ec40 100755
 +    while IFS=' :' read -r origin hash; do
 +      case "$origin" in
 +        (expected|specified) oldHash="$hash";;
-+        (got) sed -i "s|$oldHash|$(nix hash to-sri --type sha256 "$hash")|" "$default_nix"; retry=true; break;;
++        (got) sed -i "s|$oldHash|$hash|" "$default_nix"; retry=true; break;;
 +        (*) printf >&2 "%s\n" "$origin${hash:+:$hash}"
 +      esac
 +    done
 +  done
 +
-   git add "$default_nix"
--  git commit -m "$1: $version_old -> $version"
-+  git commit -m "sourcehut.$1: $oldVersion -> $version"
++  if [ "$oldVersion" != "$version" ]; then
++    git add "$default_nix"
++    git commit -m "sourcehut.$1: $oldVersion -> $version"
++  fi
  }
  
 -services=( "srht" "buildsrht" "dispatchsrht" "gitsrht" "hgsrht" "hubsrht" "listssrht" "mansrht"
-- 
2.47.2