From add1f7b7fe51da1ab7cc523d02dec880fe2614ab Mon Sep 17 00:00:00 2001 From: Marcin Serwin Date: Tue, 29 Jul 2025 17:11:56 +0200 Subject: [PATCH] fetchFromSourcehut: add tag as an alternative for rev This is just for consistency with fetchFromGitHub and fetchFromGitLab since the URLs used are the same. Signed-off-by: Marcin Serwin --- pkgs/build-support/fetchsourcehut/default.nix | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/pkgs/build-support/fetchsourcehut/default.nix b/pkgs/build-support/fetchsourcehut/default.nix index bf1b2a58b4d7..1b4a18a8837f 100644 --- a/pkgs/build-support/fetchsourcehut/default.nix +++ b/pkgs/build-support/fetchsourcehut/default.nix @@ -18,14 +18,21 @@ makeOverridable ( { owner, repo, - rev, - name ? repoRevToNameMaybe repo rev "sourcehut", + rev ? null, + tag ? null, + name ? repoRevToNameMaybe repo (lib.revOrTag rev tag) "sourcehut", domain ? "sr.ht", vc ? "git", fetchSubmodules ? false, ... # For hash agility }@args: + assert ( + lib.assertMsg (lib.xor (tag == null) ( + rev == null + )) "fetchFromSourcehut requires one of either `rev` or `tag` to be provided (not both)." + ); + assert ( assertOneOf "vc" vc [ "hg" @@ -35,6 +42,7 @@ makeOverridable ( let urlFor = resource: "https://${resource}.${domain}/${owner}/${repo}"; + rev' = if tag != null then tag else rev; baseUrl = urlFor vc; baseArgs = { inherit name; @@ -43,13 +51,14 @@ makeOverridable ( "owner" "repo" "rev" + "tag" "domain" "vc" "name" "fetchSubmodules" ]; vcArgs = baseArgs // { - inherit rev; + rev = rev'; url = baseUrl; }; fetcher = if fetchSubmodules then vc else "zip"; @@ -69,7 +78,7 @@ makeOverridable ( zip = { fetch = fetchzip; arguments = baseArgs // { - url = "${baseUrl}/archive/${rev}.tar.gz"; + url = "${baseUrl}/archive/${rev'}.tar.gz"; postFetch = optionalString (vc == "hg") '' rm -f "$out/.hg_archival.txt" ''; # impure file; see #12002 @@ -82,7 +91,7 @@ makeOverridable ( in cases.${fetcher}.fetch cases.${fetcher}.arguments // { - inherit rev; + rev = rev'; meta.homepage = "${baseUrl}"; } )