2024-06-30 08:16:52 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
fetchgit,
|
|
|
|
fetchzip,
|
|
|
|
}:
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
lib.makeOverridable (
|
2024-06-30 08:16:52 +00:00
|
|
|
# gitlab example
|
|
|
|
{
|
|
|
|
owner,
|
|
|
|
repo,
|
|
|
|
rev,
|
|
|
|
protocol ? "https",
|
|
|
|
domain ? "gitlab.com",
|
|
|
|
name ? "source",
|
|
|
|
group ? null,
|
|
|
|
fetchSubmodules ? false,
|
|
|
|
leaveDotGit ? false,
|
|
|
|
deepClone ? false,
|
|
|
|
forceFetchGit ? false,
|
|
|
|
sparseCheckout ? [ ],
|
|
|
|
... # For hash agility
|
|
|
|
}@args:
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
let
|
|
|
|
slug = lib.concatStringsSep "/" (
|
|
|
|
(lib.optional (group != null) group)
|
|
|
|
++ [
|
|
|
|
owner
|
|
|
|
repo
|
|
|
|
]
|
|
|
|
);
|
|
|
|
escapedSlug =
|
|
|
|
lib.replaceStrings
|
|
|
|
[
|
|
|
|
"."
|
|
|
|
"/"
|
|
|
|
]
|
|
|
|
[
|
|
|
|
"%2E"
|
|
|
|
"%2F"
|
|
|
|
]
|
|
|
|
slug;
|
|
|
|
escapedRev =
|
|
|
|
lib.replaceStrings
|
|
|
|
[
|
|
|
|
"+"
|
|
|
|
"%"
|
|
|
|
"/"
|
|
|
|
]
|
|
|
|
[
|
|
|
|
"%2B"
|
|
|
|
"%25"
|
|
|
|
"%2F"
|
|
|
|
]
|
|
|
|
rev;
|
|
|
|
passthruAttrs = removeAttrs args [
|
|
|
|
"protocol"
|
|
|
|
"domain"
|
|
|
|
"owner"
|
|
|
|
"group"
|
|
|
|
"repo"
|
|
|
|
"rev"
|
|
|
|
"fetchSubmodules"
|
|
|
|
"forceFetchGit"
|
|
|
|
"leaveDotGit"
|
|
|
|
"deepClone"
|
|
|
|
];
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
useFetchGit =
|
|
|
|
fetchSubmodules || leaveDotGit || deepClone || forceFetchGit || (sparseCheckout != [ ]);
|
|
|
|
fetcher = if useFetchGit then fetchgit else fetchzip;
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
gitRepoUrl = "${protocol}://${domain}/${slug}.git";
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
fetcherArgs =
|
|
|
|
(
|
|
|
|
if useFetchGit then
|
|
|
|
{
|
|
|
|
inherit
|
|
|
|
rev
|
|
|
|
deepClone
|
|
|
|
fetchSubmodules
|
|
|
|
sparseCheckout
|
|
|
|
leaveDotGit
|
|
|
|
;
|
|
|
|
url = gitRepoUrl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
url = "${protocol}://${domain}/api/v4/projects/${escapedSlug}/repository/archive.tar.gz?sha=${escapedRev}";
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
passthru = {
|
|
|
|
inherit gitRepoUrl;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
)
|
|
|
|
// passthruAttrs
|
|
|
|
// {
|
|
|
|
inherit name;
|
|
|
|
};
|
|
|
|
in
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
fetcher fetcherArgs
|
|
|
|
// {
|
|
|
|
meta.homepage = "${protocol}://${domain}/${slug}/";
|
|
|
|
inherit rev owner repo;
|
|
|
|
}
|
2024-05-02 00:46:19 +00:00
|
|
|
)
|