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 <marcin@serwin.dev>
This commit is contained in:
parent
be87108089
commit
add1f7b7fe
@ -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}";
|
||||
}
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user