fetchFromSourcehut: allow recursive fetching

main
Nguyễn Gia Phong 3 years ago
parent ce789257bb
commit b97ccaa18d
No known key found for this signature in database
GPG Key ID: 27148B2C06A2224B
  1. 9
      doc/builders/fetchers.chapter.md
  2. 9
      nixos/doc/manual/from_md/release-notes/rl-2205.section.xml
  3. 4
      nixos/doc/manual/release-notes/rl-2205.section.md
  4. 45
      pkgs/build-support/fetchsourcehut/default.nix

@ -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`.

@ -310,6 +310,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>

@ -116,3 +116,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 {
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}";
}

Loading…
Cancel
Save