From 0f4642c7961dfc1348b607f47ff8c9a8cf6b3656 Mon Sep 17 00:00:00 2001 From: Defelo Date: Sun, 17 Aug 2025 03:34:56 +0200 Subject: [PATCH] fetchFromRadicle: init --- doc/build-helpers/fetchers.chapter.md | 18 +++++++++ doc/redirects.json | 3 ++ pkgs/build-support/fetchradicle/default.nix | 44 +++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 4 files changed, 67 insertions(+) create mode 100644 pkgs/build-support/fetchradicle/default.nix diff --git a/doc/build-helpers/fetchers.chapter.md b/doc/build-helpers/fetchers.chapter.md index 6a6ebe9013c2..08b978e720dc 100644 --- a/doc/build-helpers/fetchers.chapter.md +++ b/doc/build-helpers/fetchers.chapter.md @@ -896,6 +896,24 @@ If `fetchSubmodules` is `true`, `fetchFromSourcehut` uses `fetchgit` or `fetchhg` with `fetchSubmodules` or `fetchSubrepos` set to `true`, respectively. Otherwise, the fetcher uses `fetchzip`. +## `fetchFromRadicle` {#fetchfromradicle} + +This is used with Radicle repositories. The arguments expected are similar to `fetchgit`. + +Requires a `seed` argument (e.g. `seed.radicle.xyz` or `rosa.radicle.xyz`) and a `repo` argument +(the repository id *without* the `rad:` prefix). Also accepts an optional `node` argument which +contains the id of the node from which to fetch the specified ref. If `node` is `null` (the +default), a canonical ref is fetched instead. + +```nix +fetchFromRadicle { + seed = "seed.radicle.xyz"; + repo = "z3gqcJUoA1n9HaHKufZs5FCSGazv5"; # heartwood + tag = "releases/1.3.0"; + hash = "sha256-4o88BWKGGOjCIQy7anvzbA/kPOO+ZsLMzXJhE61odjw="; +} +``` + ## `requireFile` {#requirefile} `requireFile` allows requesting files that cannot be fetched automatically, but whose content is known. diff --git a/doc/redirects.json b/doc/redirects.json index 8210470b5bcb..cb43dbf9ff23 100644 --- a/doc/redirects.json +++ b/doc/redirects.json @@ -1657,6 +1657,9 @@ "fetchfromsourcehut": [ "index.html#fetchfromsourcehut" ], + "fetchfromradicle": [ + "index.html#fetchfromradicle" + ], "requirefile": [ "index.html#requirefile" ], diff --git a/pkgs/build-support/fetchradicle/default.nix b/pkgs/build-support/fetchradicle/default.nix new file mode 100644 index 000000000000..a8102c382c02 --- /dev/null +++ b/pkgs/build-support/fetchradicle/default.nix @@ -0,0 +1,44 @@ +{ lib, fetchgit }: + +lib.makeOverridable ( + { + seed, + repo, + node ? null, + rev ? null, + tag ? null, + ... + }@args: + + assert lib.assertMsg (lib.xor (tag != null) ( + rev != null + )) "fetchFromRadicle requires one of either `rev` or `tag` to be provided (not both)."; + + let + namespacePrefix = lib.optionalString (node != null) "refs/namespaces/${node}/"; + rev' = if tag != null then "refs/tags/${tag}" else rev; + in + + fetchgit ( + { + url = "https://${seed}/${repo}.git"; + rev = "${namespacePrefix}${rev'}"; + } + // removeAttrs args [ + "seed" + "repo" + "node" + "rev" + "tag" + ] + ) + // { + inherit + seed + repo + node + rev + tag + ; + } +) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 4c60ad7b5884..0e51a150197f 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -697,6 +697,8 @@ with pkgs; fetchFromRepoOrCz = callPackage ../build-support/fetchrepoorcz { }; + fetchFromRadicle = callPackage ../build-support/fetchradicle { }; + fetchgx = callPackage ../build-support/fetchgx { }; fetchPypi = callPackage ../build-support/fetchpypi { };