Skip to content

Commit

Permalink
unstableGitUpdater: fix updating fetchzip-based sources
Browse files Browse the repository at this point in the history
a67950f 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.
  • Loading branch information
jtojnar committed May 24, 2022
1 parent 1daa1ed commit 7aae279
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
4 changes: 4 additions & 0 deletions pkgs/build-support/fetchgit/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,8 @@ stdenvNoCC.mkDerivation {
];

inherit preferLocalBuild meta;

passthru = {
gitRepoUrl = url;
};
}
13 changes: 11 additions & 2 deletions pkgs/build-support/fetchgithub/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,20 @@ let
'';
netrcImpureEnvVars = [ "${varBase}USERNAME" "${varBase}PASSWORD" ];
};

gitRepoUrl = "${baseUrl}.git";

fetcherArgs = (if useFetchGit
then {
inherit rev deepClone fetchSubmodules sparseCheckout; url = "${baseUrl}.git";
inherit rev deepClone fetchSubmodules sparseCheckout; url = gitRepoUrl;
} // 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; };
in

Expand Down
8 changes: 7 additions & 1 deletion pkgs/build-support/fetchgitlab/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@ let
useFetchGit = deepClone || fetchSubmodules || leaveDotGit;
fetcher = if useFetchGit then fetchgit else fetchzip;

gitRepoUrl = "${protocol}:https://${domain}/${slug}.git";

fetcherArgs = (if useFetchGit then {
inherit rev deepClone fetchSubmodules leaveDotGit;
url = "${protocol}:https://${domain}/${slug}.git";
url = gitRepoUrl;
} else {
url = "${protocol}:https://${domain}/api/v4/projects/${escapedSlug}/repository/archive.tar.gz?sha=${escapedRev}";

passthru = {
inherit gitRepoUrl;
};
}) // passthruAttrs // { inherit name; };
in

Expand Down
2 changes: 1 addition & 1 deletion pkgs/common-updater/unstable-updater.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ let
# By default we set url to src.url
if [[ -z "$url" ]]; then
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 '"')"
fi
Expand Down

0 comments on commit 7aae279

Please sign in to comment.