diff options
Diffstat (limited to 'pkgs/build-support/fetchsourcehut/default.nix')
-rw-r--r-- | pkgs/build-support/fetchsourcehut/default.nix | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/pkgs/build-support/fetchsourcehut/default.nix b/pkgs/build-support/fetchsourcehut/default.nix index ed2f074200c..2b1feaa496e 100644 --- a/pkgs/build-support/fetchsourcehut/default.nix +++ b/pkgs/build-support/fetchsourcehut/default.nix @@ -1,10 +1,11 @@ -{ fetchzip, lib }: +{ fetchgit, fetchhg, fetchzip, lib }: { owner , repo, rev , domain ? "sr.ht" , vc ? "git" , name ? "source" +, fetchSubmodules ? false , ... # For hash agility } @ args: @@ -14,12 +15,36 @@ assert (lib.assertOneOf "vc" vc [ "hg" "git" ]); let baseUrl = "https://${vc}.${domain}/${owner}/${repo}"; - -in fetchzip (recursiveUpdate { - inherit name; - url = "${baseUrl}/archive/${rev}.tar.gz"; - meta.homepage = "${baseUrl}/"; - extraPostFetch = optionalString (vc == "hg") '' - rm -f "$out/.hg_archival.txt" - ''; # impure file; see #12002 -} (removeAttrs args [ "owner" "repo" "rev" "domain" "vc" ])) // { inherit rev; } + baseArgs = { + inherit name; + } // removeAttrs args [ + "owner" "repo" "rev" "domain" "vc" "name" "fetchSubmodules" + ]; + vcArgs = baseArgs // { + inherit rev; + url = baseUrl; + }; + fetcher = if fetchSubmodules then vc else "zip"; + cases = { + git = { + fetch = fetchgit; + arguments = vcArgs // { fetchSubmodules = true; }; + }; + hg = { + fetch = fetchhg; + arguments = vcArgs // { fetchSubrepos = true; }; + }; + zip = { + fetch = fetchzip; + arguments = baseArgs // { + url = "${baseUrl}/archive/${rev}.tar.gz"; + extraPostFetch = optionalString (vc == "hg") '' + rm -f "$out/.hg_archival.txt" + ''; # impure file; see #12002 + }; + }; + }; +in cases.${fetcher}.fetch cases.${fetcher}.arguments // { + inherit rev; + meta.homepage = "${baseUrl}"; +} |