fetchFromGitHub: take passthru and enhance overriding

Take optional argument `passthru` for custom passthru attribute set.

Update the `meta` attribute via `<pkg>.overrideAttrs` instead of
attribute set update (`//`).

Attach attributes `owner`, `repo` and `rev` via `passthru` instead of
attribute set update.
This commit is contained in:
Yueh-Shun Li 2024-03-09 00:01:11 +08:00 committed by Abhiram
parent ff4126b6ba
commit ef1e2ef8c2

View file

@ -8,6 +8,7 @@ lib.makeOverridable (
, deepClone ? false, private ? false, forceFetchGit ? false
, sparseCheckout ? []
, githubBase ? "github.com", varPrefix ? null
, passthru ? { }
, meta ? { }
, ... # For hash agility
}@args:
@ -21,6 +22,9 @@ let
else builtins.unsafeGetAttrPos "rev" args
);
baseUrl = "https://${githubBase}/${owner}/${repo}";
newPassthru = passthru // {
inherit rev owner repo;
};
newMeta = meta // {
homepage = meta.homepage or baseUrl;
} // lib.optionalAttrs (position != null) {
@ -57,16 +61,19 @@ let
fetcherArgs = (if useFetchGit
then {
inherit rev deepClone fetchSubmodules sparseCheckout; url = gitRepoUrl;
passthru = newPassthru;
} // lib.optionalAttrs (leaveDotGit != null) { inherit leaveDotGit; }
else {
url = "${baseUrl}/archive/${rev}.tar.gz";
passthru = {
passthru = newPassthru // {
inherit gitRepoUrl;
};
}
) // privateAttrs // passthruAttrs // { inherit name; };
in
fetcher fetcherArgs // { meta = newMeta; inherit rev owner repo; }
(fetcher fetcherArgs).overrideAttrs (finalAttrs: previousAttrs: {
meta = newMeta;
})
)