unstableGitUpdater: fix updating fetchzip-based sources

a67950f20b added `url` attribute
from `fetchurl` and therefore also from `fetchzip`.
We previously relied on `url` from fetchgit-based fetchers
to find the repo URL but now it will just return tarballs
in the case of `fetchFrom{GitHub,GitLab}`.

Let’s add an attribute to `fetch{git,FromGitHub,FromGitLab}`
to expose a repo URL consistently.
This commit is contained in:
Jan Tojnar 2022-05-24 18:03:46 +02:00
parent 1daa1ede66
commit 7aae279ad9
4 changed files with 23 additions and 4 deletions

View File

@ -92,4 +92,8 @@ stdenvNoCC.mkDerivation {
]; ];
inherit preferLocalBuild meta; inherit preferLocalBuild meta;
passthru = {
gitRepoUrl = url;
};
} }

View File

@ -42,11 +42,20 @@ let
''; '';
netrcImpureEnvVars = [ "${varBase}USERNAME" "${varBase}PASSWORD" ]; netrcImpureEnvVars = [ "${varBase}USERNAME" "${varBase}PASSWORD" ];
}; };
gitRepoUrl = "${baseUrl}.git";
fetcherArgs = (if useFetchGit fetcherArgs = (if useFetchGit
then { then {
inherit rev deepClone fetchSubmodules sparseCheckout; url = "${baseUrl}.git"; inherit rev deepClone fetchSubmodules sparseCheckout; url = gitRepoUrl;
} // lib.optionalAttrs (leaveDotGit != null) { inherit leaveDotGit; } } // lib.optionalAttrs (leaveDotGit != null) { inherit leaveDotGit; }
else { url = "${baseUrl}/archive/${rev}.tar.gz"; } else {
url = "${baseUrl}/archive/${rev}.tar.gz";
passthru = {
inherit gitRepoUrl;
};
}
) // privateAttrs // passthruAttrs // { inherit name; }; ) // privateAttrs // passthruAttrs // { inherit name; };
in in

View File

@ -15,11 +15,17 @@ let
useFetchGit = deepClone || fetchSubmodules || leaveDotGit; useFetchGit = deepClone || fetchSubmodules || leaveDotGit;
fetcher = if useFetchGit then fetchgit else fetchzip; fetcher = if useFetchGit then fetchgit else fetchzip;
gitRepoUrl = "${protocol}://${domain}/${slug}.git";
fetcherArgs = (if useFetchGit then { fetcherArgs = (if useFetchGit then {
inherit rev deepClone fetchSubmodules leaveDotGit; inherit rev deepClone fetchSubmodules leaveDotGit;
url = "${protocol}://${domain}/${slug}.git"; url = gitRepoUrl;
} else { } else {
url = "${protocol}://${domain}/api/v4/projects/${escapedSlug}/repository/archive.tar.gz?sha=${escapedRev}"; url = "${protocol}://${domain}/api/v4/projects/${escapedSlug}/repository/archive.tar.gz?sha=${escapedRev}";
passthru = {
inherit gitRepoUrl;
};
}) // passthruAttrs // { inherit name; }; }) // passthruAttrs // { inherit name; };
in in

View File

@ -49,7 +49,7 @@ let
# By default we set url to src.url # By default we set url to src.url
if [[ -z "$url" ]]; then if [[ -z "$url" ]]; then
url="$(${nix}/bin/nix-instantiate $systemArg --eval -E \ url="$(${nix}/bin/nix-instantiate $systemArg --eval -E \
"with import ./. {}; $UPDATE_NIX_ATTR_PATH.src.url or $UPDATE_NIX_ATTR_PATH.src.meta.homepage" \ "with import ./. {}; $UPDATE_NIX_ATTR_PATH.src.gitRepoUrl" \
| tr -d '"')" | tr -d '"')"
fi fi