Merge pull request #148606 from McSinyx/fetch-srht-recurse
fetchFromSourcehut: allow recursive fetching
This commit is contained in:
commit
952aa6f820
@ -82,4 +82,11 @@ This is used with repo.or.cz repositories. The arguments expected are very simil
|
||||
|
||||
## `fetchFromSourcehut` {#fetchfromsourcehut}
|
||||
|
||||
This is used with sourcehut repositories. The arguments expected are very similar to fetchFromGitHub above. Don't forget the tilde (~) in front of the user name!
|
||||
This is used with sourcehut repositories. Similar to `fetchFromGitHub` above,
|
||||
it expects `owner`, `repo`, `rev` and `sha256`, but don't forget the tilde (~)
|
||||
in front of the username! Expected arguments also include `vc` ("git" (default)
|
||||
or "hg"), `domain` and `fetchSubmodules`.
|
||||
|
||||
If `fetchSubmodules` is `true`, `fetchFromSourcehut` uses `fetchgit`
|
||||
or `fetchhg` with `fetchSubmodules` or `fetchSubrepos` set to `true`,
|
||||
respectively. Otherwise the fetcher uses `fetchzip`.
|
||||
|
@ -325,6 +325,15 @@
|
||||
files.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>fetchFromSourcehut</literal> now allows fetching
|
||||
repositories recursively using <literal>fetchgit</literal> or
|
||||
<literal>fetchhg</literal> if the argument
|
||||
<literal>fetchSubmodules</literal> is set to
|
||||
<literal>true</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
</section>
|
||||
|
@ -120,3 +120,7 @@ In addition to numerous new and upgraded packages, this release has the followin
|
||||
- The `services.stubby` module was converted to a [settings-style](https://github.com/NixOS/rfcs/blob/master/rfcs/0042-config-option.md) configuration.
|
||||
|
||||
- The option `services.duplicati.dataDir` has been added to allow changing the location of duplicati's files.
|
||||
|
||||
- `fetchFromSourcehut` now allows fetching repositories recursively
|
||||
using `fetchgit` or `fetchhg` if the argument `fetchSubmodules`
|
||||
is set to `true`.
|
||||
|
@ -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 {
|
||||
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";
|
||||
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; }
|
||||
};
|
||||
};
|
||||
};
|
||||
in cases.${fetcher}.fetch cases.${fetcher}.arguments // {
|
||||
inherit rev;
|
||||
meta.homepage = "${baseUrl}";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user