2021-07-22 11:29:02 +02:00
|
|
|
{ fetchgit, fetchzip, lib }:
|
2019-01-26 16:06:25 +01:00
|
|
|
|
|
|
|
# gitlab example
|
|
|
|
{ owner, repo, rev, domain ? "gitlab.com", name ? "source", group ? null
|
2021-07-22 11:29:02 +02:00
|
|
|
, fetchSubmodules ? false, leaveDotGit ? false, deepClone ? false
|
2019-01-26 16:06:25 +01:00
|
|
|
, ... # For hash agility
|
2019-11-24 20:54:46 +01:00
|
|
|
} @ args:
|
|
|
|
|
|
|
|
let
|
2021-07-22 11:29:02 +02:00
|
|
|
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 [ "domain" "owner" "group" "repo" "rev" ];
|
|
|
|
|
|
|
|
useFetchGit = deepClone || fetchSubmodules || leaveDotGit;
|
|
|
|
fetcher = if useFetchGit then fetchgit else fetchzip;
|
2019-11-24 20:54:46 +01:00
|
|
|
|
2021-07-22 11:29:02 +02:00
|
|
|
fetcherArgs = (if useFetchGit then {
|
|
|
|
inherit rev deepClone fetchSubmodules leaveDotGit;
|
|
|
|
url = "https://${domain}/${slug}.git";
|
|
|
|
} else {
|
|
|
|
url = "https://${domain}/api/v4/projects/${escapedSlug}/repository/archive.tar.gz?sha=${escapedRev}";
|
|
|
|
}) // passthruAttrs // { inherit name; };
|
2019-11-24 20:54:46 +01:00
|
|
|
in
|
|
|
|
|
2021-07-22 11:29:02 +02:00
|
|
|
fetcher fetcherArgs // { meta.homepage = "https://${domain}/${slug}/"; inherit rev; }
|