Skip to content

Commit 39f09b0

Browse files
fetchFromRadicle: init (#434360)
2 parents 74042be + 914c4f2 commit 39f09b0

File tree

9 files changed

+92
-23
lines changed

9 files changed

+92
-23
lines changed

doc/build-helpers/fetchers.chapter.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,24 @@ If `fetchSubmodules` is `true`, `fetchFromSourcehut` uses `fetchgit`
896896
or `fetchhg` with `fetchSubmodules` or `fetchSubrepos` set to `true`,
897897
respectively. Otherwise, the fetcher uses `fetchzip`.
898898

899+
## `fetchFromRadicle` {#fetchfromradicle}
900+
901+
This is used with Radicle repositories. The arguments expected are similar to `fetchgit`.
902+
903+
Requires a `seed` argument (e.g. `seed.radicle.xyz` or `rosa.radicle.xyz`) and a `repo` argument
904+
(the repository id *without* the `rad:` prefix). Also accepts an optional `node` argument which
905+
contains the id of the node from which to fetch the specified ref. If `node` is `null` (the
906+
default), a canonical ref is fetched instead.
907+
908+
```nix
909+
fetchFromRadicle {
910+
seed = "seed.radicle.xyz";
911+
repo = "z3gqcJUoA1n9HaHKufZs5FCSGazv5"; # heartwood
912+
tag = "releases/1.3.0";
913+
hash = "sha256-4o88BWKGGOjCIQy7anvzbA/kPOO+ZsLMzXJhE61odjw=";
914+
}
915+
```
916+
899917
## `requireFile` {#requirefile}
900918

901919
`requireFile` allows requesting files that cannot be fetched automatically, but whose content is known.

doc/redirects.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,6 +1666,9 @@
16661666
"fetchfromsourcehut": [
16671667
"index.html#fetchfromsourcehut"
16681668
],
1669+
"fetchfromradicle": [
1670+
"index.html#fetchfromradicle"
1671+
],
16691672
"requirefile": [
16701673
"index.html#requirefile"
16711674
],
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{ lib, fetchgit }:
2+
3+
lib.makeOverridable (
4+
{
5+
seed,
6+
repo,
7+
node ? null,
8+
rev ? null,
9+
tag ? null,
10+
...
11+
}@args:
12+
13+
assert lib.assertMsg (lib.xor (tag != null) (
14+
rev != null
15+
)) "fetchFromRadicle requires one of either `rev` or `tag` to be provided (not both).";
16+
17+
let
18+
namespacePrefix = lib.optionalString (node != null) "refs/namespaces/${node}/";
19+
rev' = if tag != null then "refs/tags/${tag}" else rev;
20+
in
21+
22+
fetchgit (
23+
{
24+
url = "https://${seed}/${repo}.git";
25+
rev = "${namespacePrefix}${rev'}";
26+
}
27+
// removeAttrs args [
28+
"seed"
29+
"repo"
30+
"node"
31+
"rev"
32+
"tag"
33+
]
34+
)
35+
// {
36+
inherit
37+
seed
38+
repo
39+
node
40+
rev
41+
tag
42+
;
43+
}
44+
)

pkgs/by-name/ra/radicle-explorer/package.nix

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
radicle-httpd,
33
fetchFromGitHub,
4-
fetchgit,
54
lib,
65
buildNpmPackage,
76
writeText,
@@ -75,9 +74,9 @@ lib.fix (
7574
# same repo. For this reason we pin the sources to each other, but due to
7675
# radicle-httpd using a more limited sparse checkout we need to carry a
7776
# separate hash.
78-
src = fetchgit {
79-
inherit (radicle-httpd.src) url rev;
80-
hash = "sha256-HRSrLdiDETTWNF+Rzvlg1XQerXcCE2xaY+6Xbq5pItI=";
77+
src = radicle-httpd.src.override {
78+
hash = "sha256-1OhZ0x21NlZIiTPCRpvdUsx5UmeLecTjVzH8DWllPr8=";
79+
sparseCheckout = [ ];
8180
};
8281

8382
postPatch = ''

pkgs/by-name/ra/radicle-httpd/package.nix

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
asciidoctor,
3-
fetchgit,
3+
fetchFromRadicle,
44
git,
55
installShellFiles,
66
lib,
@@ -16,11 +16,13 @@ rustPlatform.buildRustPackage rec {
1616
env.RADICLE_VERSION = version;
1717

1818
# You must update the radicle-explorer source hash when changing this.
19-
src = fetchgit {
20-
url = "https://seed.radicle.xyz/z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git";
21-
rev = "refs/namespaces/z6MkireRatUThvd3qzfKht1S44wpm4FEWSSa4PRMTSQZ3voM/refs/tags/v${version}";
22-
hash = "sha256-9rJH4ECqOJ9wnYxCbEFHXo3PlhbPdeOnF+Pf1MzX25c=";
19+
src = fetchFromRadicle {
20+
seed = "seed.radicle.xyz";
21+
repo = "z4V1sjrXqjvFdnCUbxPFqd5p4DtH5";
22+
node = "z6MkireRatUThvd3qzfKht1S44wpm4FEWSSa4PRMTSQZ3voM";
23+
tag = "v${version}";
2324
sparseCheckout = [ "radicle-httpd" ];
25+
hash = "sha256-9rJH4ECqOJ9wnYxCbEFHXo3PlhbPdeOnF+Pf1MzX25c=";
2426
};
2527

2628
sourceRoot = "${src.name}/radicle-httpd";

pkgs/by-name/ra/radicle-node/package.nix

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
asciidoctor,
3-
fetchgit,
3+
fetchFromRadicle,
44
git,
55
installShellFiles,
66
jq,
@@ -22,9 +22,11 @@ rustPlatform.buildRustPackage rec {
2222
version = "1.3.0";
2323
env.RADICLE_VERSION = version;
2424

25-
src = fetchgit {
26-
url = "https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5.git";
27-
rev = "refs/namespaces/z6MkireRatUThvd3qzfKht1S44wpm4FEWSSa4PRMTSQZ3voM/refs/tags/v${version}";
25+
src = fetchFromRadicle {
26+
seed = "seed.radicle.xyz";
27+
repo = "z3gqcJUoA1n9HaHKufZs5FCSGazv5";
28+
node = "z6MkireRatUThvd3qzfKht1S44wpm4FEWSSa4PRMTSQZ3voM";
29+
tag = "v${version}";
2830
hash = "sha256-0gK+fM/YGGpxlcR1HQixbLK0/sv+HH29h6ajEP2w2pI=";
2931
leaveDotGit = true;
3032
postFetch = ''

pkgs/by-name/ra/radicle-tui/package.nix

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
lib,
33
rustPlatform,
4-
fetchgit,
4+
fetchFromRadicle,
55
stdenv,
66
libiconv,
77
zlib,
@@ -13,9 +13,11 @@ rustPlatform.buildRustPackage (finalAttrs: {
1313
pname = "radicle-tui";
1414
version = "0.6.0";
1515

16-
src = fetchgit {
17-
url = "https://seed.radicle.xyz/z39mP9rQAaGmERfUMPULfPUi473tY.git";
18-
rev = "refs/namespaces/z6MkswQE8gwZw924amKatxnNCXA55BMupMmRg7LvJuim2C1V/refs/tags/${finalAttrs.version}";
16+
src = fetchFromRadicle {
17+
seed = "seed.radicle.xyz";
18+
repo = "z39mP9rQAaGmERfUMPULfPUi473tY";
19+
node = "z6MkswQE8gwZw924amKatxnNCXA55BMupMmRg7LvJuim2C1V";
20+
tag = finalAttrs.version;
1921
hash = "sha256-rz9l9GtycqZoROUI6Hn0Fv5Br0YCIrcHlEWLMP4hasQ=";
2022
leaveDotGit = true;
2123
postFetch = ''

pkgs/by-name/ra/radicle-tui/update.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@ set -euo pipefail
66
dirname="$(dirname "${BASH_SOURCE[0]}")"
77

88
url=$(nix-instantiate --eval --raw -A radicle-tui.src.url)
9-
old_ref=$(nix-instantiate --eval --raw -A radicle-tui.src.rev)
10-
new_ref=$(git ls-remote "$url" 'refs/namespaces/*/refs/tags/*' | cut -f2 | tail -1)
9+
old_node=$(nix-instantiate --eval --raw -A radicle-tui.src.node)
1110

12-
[[ "$old_ref" =~ ^refs/namespaces/([^/]+)/refs/tags/([^/]+)$ ]]
13-
old_node="${BASH_REMATCH[1]}"
14-
15-
[[ "$new_ref" =~ ^refs/namespaces/([^/]+)/refs/tags/([^/]+)$ ]]
11+
ref=$(git ls-remote "$url" 'refs/namespaces/*/refs/tags/*' | cut -f2 | tail -1)
12+
[[ "$ref" =~ ^refs/namespaces/([^/]+)/refs/tags/([^/]+)$ ]]
1613
new_node="${BASH_REMATCH[1]}"
1714
version="${BASH_REMATCH[2]}"
1815

pkgs/top-level/all-packages.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,8 @@ with pkgs;
697697

698698
fetchFromRepoOrCz = callPackage ../build-support/fetchrepoorcz { };
699699

700+
fetchFromRadicle = callPackage ../build-support/fetchradicle { };
701+
700702
fetchgx = callPackage ../build-support/fetchgx { };
701703

702704
fetchPypi = callPackage ../build-support/fetchpypi { };

0 commit comments

Comments
 (0)