Unverified Commit 39f09b02 authored by Sandro Jäckel's avatar Sandro Jäckel Committed by GitHub
Browse files

fetchFromRadicle: init (#434360)

parents 74042be7 914c4f23
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -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.
+3 −0
Original line number Diff line number Diff line
@@ -1666,6 +1666,9 @@
  "fetchfromsourcehut": [
    "index.html#fetchfromsourcehut"
  ],
  "fetchfromradicle": [
    "index.html#fetchfromradicle"
  ],
  "requirefile": [
    "index.html#requirefile"
  ],
+44 −0
Original line number Diff line number Diff line
{ 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
      ;
  }
)
+3 −4
Original line number Diff line number Diff line
{
  radicle-httpd,
  fetchFromGitHub,
  fetchgit,
  lib,
  buildNpmPackage,
  writeText,
@@ -75,9 +74,9 @@ lib.fix (
      # same repo. For this reason we pin the sources to each other, but due to
      # radicle-httpd using a more limited sparse checkout we need to carry a
      # separate hash.
      src = fetchgit {
        inherit (radicle-httpd.src) url rev;
        hash = "sha256-HRSrLdiDETTWNF+Rzvlg1XQerXcCE2xaY+6Xbq5pItI=";
      src = radicle-httpd.src.override {
        hash = "sha256-1OhZ0x21NlZIiTPCRpvdUsx5UmeLecTjVzH8DWllPr8=";
        sparseCheckout = [ ];
      };

      postPatch = ''
+7 −5
Original line number Diff line number Diff line
{
  asciidoctor,
  fetchgit,
  fetchFromRadicle,
  git,
  installShellFiles,
  lib,
@@ -16,11 +16,13 @@ rustPlatform.buildRustPackage rec {
  env.RADICLE_VERSION = version;

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

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