Skip to content

Commit f6c31a3

Browse files
tazjinEmery Hemingway
authored andcommitted
radicle-explorer: init at 0.17.0
This commit adds radicle-explorer, a web interface for Radicle which displays repositories, issues and patches. The package builds the web interface itself, but a web server still needs to be configured to serve it. This is out-of-scope for this commit, but may be added to the related NixOS modules in the future. The web interface is based on the API exposed by radicle-httpd. For this reason the sources and version of the web interface have been tied directly to the radicle-httpd package, necessitating corresponding updates on this package whenever httpd is updated. There's a little bit of fixed-point magic in this change to enable two features: * Overriding build-time configuration (required to, for example, display a different Radicle seed by default). Documentation for this is available in the upstream repo. * Building radicle-explorer without plausible, a web tracking package which sends user-data to a remote host by default. These are configured through slightly different overriding mechanisms, but I hope to simplify this in the future with some upstream patches.
1 parent a7e62e6 commit f6c31a3

File tree

3 files changed

+209
-0
lines changed

3 files changed

+209
-0
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
From cc4718cbea1bd70de21a2be515a944802246ffc7 Mon Sep 17 00:00:00 2001
2+
From: Vincent Ambo <[email protected]>
3+
Date: Sun, 15 Sep 2024 03:08:28 +0300
4+
Subject: [PATCH] remove dependency on plausible
5+
6+
---
7+
package-lock.json | 9 ---------
8+
package.json | 1 -
9+
src/App.svelte | 8 --------
10+
3 files changed, 18 deletions(-)
11+
12+
diff --git a/package-lock.json b/package-lock.json
13+
index d52de6c0..d96e342f 100644
14+
--- a/package-lock.json
15+
+++ b/package-lock.json
16+
@@ -29,7 +29,6 @@
17+
"marked-katex-extension": "^5.1.1",
18+
"marked-linkify-it": "^3.1.11",
19+
"md5": "^2.3.0",
20+
- "plausible-tracker": "^0.3.9",
21+
"svelte": "^4.2.19",
22+
"twemoji": "^14.0.2",
23+
"zod": "^3.23.8"
24+
@@ -3697,14 +3696,6 @@
25+
"url": "https://github.com/sponsors/jonschlinkert"
26+
}
27+
},
28+
- "node_modules/plausible-tracker": {
29+
- "version": "0.3.9",
30+
- "resolved": "https://registry.npmjs.org/plausible-tracker/-/plausible-tracker-0.3.9.tgz",
31+
- "integrity": "sha512-hMhneYm3GCPyQon88SZrVJx+LlqhM1kZFQbuAgXPoh/Az2YvO1B6bitT9qlhpiTdJlsT5lsr3gPmzoVjb5CDXA==",
32+
- "engines": {
33+
- "node": ">=10"
34+
- }
35+
- },
36+
"node_modules/playwright": {
37+
"version": "1.46.1",
38+
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.46.1.tgz",
39+
diff --git a/package.json b/package.json
40+
index 6d569ad9..61e8d892 100644
41+
--- a/package.json
42+
+++ b/package.json
43+
@@ -73,7 +73,6 @@
44+
"marked-katex-extension": "^5.1.1",
45+
"marked-linkify-it": "^3.1.11",
46+
"md5": "^2.3.0",
47+
- "plausible-tracker": "^0.3.9",
48+
"svelte": "^4.2.19",
49+
"twemoji": "^14.0.2",
50+
"zod": "^3.23.8"
51+
diff --git a/src/App.svelte b/src/App.svelte
52+
index 8161c390..4281ba61 100644
53+
--- a/src/App.svelte
54+
+++ b/src/App.svelte
55+
@@ -1,6 +1,4 @@
56+
<script lang="ts">
57+
- import Plausible from "plausible-tracker";
58+
-
59+
import * as router from "@app/lib/router";
60+
import { unreachable } from "@app/lib/utils";
61+
62+
@@ -28,12 +26,6 @@
63+
64+
void router.loadFromLocation();
65+
66+
- if (import.meta.env.PROD) {
67+
- const plausible = Plausible({ domain: "app.radicle.xyz" });
68+
-
69+
- plausible.enableAutoPageviews();
70+
- }
71+
-
72+
$: document.documentElement.setAttribute("data-codefont", $codeFont);
73+
$: document.documentElement.setAttribute("data-theme", $theme);
74+
</script>
75+
--
76+
2.46.0
77+
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
{
2+
radicle-httpd,
3+
fetchFromGitHub,
4+
fetchgit,
5+
lib,
6+
buildNpmPackage,
7+
writeText,
8+
jq,
9+
runCommand,
10+
}:
11+
12+
let
13+
# radicle-explorer bundles these freely available Emoji assets, but does not
14+
# redistribute them.
15+
twemojiAssets = fetchFromGitHub {
16+
owner = "twitter";
17+
repo = "twemoji";
18+
rev = "v14.0.2";
19+
hash = "sha256-YoOnZ5uVukzi/6bLi22Y8U5TpplPzB7ji42l+/ys5xI=";
20+
meta.license = [ lib.licenses.cc-by-40 ];
21+
};
22+
23+
mkPassthru = self: args: {
24+
# radicle-explorer is configured through static build time configuration.
25+
#
26+
# Using this function you can override the this configuration, for example,
27+
# to configure alternative preferred peers (which are shown in the UI by
28+
# default).
29+
#
30+
# Example usage:
31+
#
32+
# ```nix
33+
# radicle-explorer.withConfig {
34+
# preferredSeeds = [{
35+
# hostname = "seed.example.com";
36+
# port = 443;
37+
# scheme = "https";
38+
# }];
39+
# }
40+
# ```
41+
withConfig =
42+
config:
43+
let
44+
overrides = writeText "config-overrides.json" (builtins.toJSON config);
45+
newConfig = runCommand "config.json" { } ''
46+
${jq}/bin/jq -s '.[0] * .[1]' ${(self args).src}/config/default.json ${overrides} > $out
47+
'';
48+
in
49+
lib.fix (
50+
final:
51+
(self args).overrideAttrs (prev: {
52+
preBuild = ''
53+
${prev.preBuild or ""}
54+
cp ${newConfig} config/local.json
55+
'';
56+
57+
passthru = prev.passthru // mkPassthru final args;
58+
})
59+
);
60+
61+
# By default, radicle-explorer includes a dependency that sends requests
62+
# to a web analytics tracking service. Using this attribute yields a
63+
# version of radicle-explorer with this dependency removed.
64+
withoutTrackers = self {
65+
patches = [ ./0001-remove-dependency-on-plausible.patch ];
66+
npmDepsHash = "sha256:1hbrzfjkfc0q8qk03yi6qb9zqm57h7hnkn7fl0yxkrzbrljaljaz";
67+
};
68+
};
69+
in
70+
lib.fix (
71+
self:
72+
lib.makeOverridable (
73+
{
74+
npmDepsHash ? "sha256:0kw6rvqm0s21j1rss35idvgcrzzczfy6qi3323y385djw4ygk5xs",
75+
patches ? [ ],
76+
}@args:
77+
buildNpmPackage {
78+
pname = "radicle-explorer";
79+
version = radicle-httpd.version;
80+
inherit patches npmDepsHash;
81+
82+
# radicle-explorer uses the radicle-httpd API, and they are developed in the
83+
# same repo. For this reason we pin the sources to each other, but due to
84+
# radicle-httpd using a more limited sparse checkout we need to carry a
85+
# separate hash.
86+
src = fetchgit {
87+
inherit (radicle-httpd.src) url rev;
88+
hash = "sha256:09m13238h6j7g02r6332ihgyyzbjx90pgz14rz29pgv7936h6il8";
89+
};
90+
91+
postPatch = ''
92+
patchShebangs --build ./scripts
93+
mkdir -p "public/twemoji"
94+
cp -t public/twemoji -r -- ${twemojiAssets}/assets/svg/*
95+
: >scripts/install-twemoji-assets
96+
'';
97+
98+
dontConfigure = true;
99+
doCheck = false;
100+
101+
installPhase = ''
102+
runHook preInstall
103+
mkdir -p "$out"
104+
cp -r -t "$out" build/*
105+
runHook postInstall
106+
'';
107+
108+
passthru = mkPassthru self args;
109+
110+
meta = {
111+
description = "Web frontend for Radicle";
112+
longDescription = ''
113+
Radicle Explorer is a web-frontend for Radicle which supports browsing
114+
repositories, issues and patches on publicly available Radicle seeds.
115+
116+
This package builds the web interface, ready to be served by any web
117+
server.
118+
'';
119+
120+
homepage = "https://radicle.xyz";
121+
license = lib.licenses.gpl3;
122+
123+
maintainers = with lib.maintainers; [
124+
tazjin
125+
lorenzleutgeb
126+
];
127+
};
128+
}
129+
)
130+
) { }

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ rustPlatform.buildRustPackage rec {
1616
version = "0.17.0";
1717
env.RADICLE_VERSION = version;
1818

19+
# You must update the radicle-explorer source hash when changing this.
1920
src = fetchgit {
2021
url = "https://seed.radicle.xyz/z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git";
2122
rev = "refs/namespaces/z6MkkfM3tPXNPrPevKr3uSiQtHPuwnNhu2yUVjgd2jXVsVz5/refs/tags/v${version}";
2223
hash = "sha256-nstyb1rSll3Sl0DlA9JAAwvr6JN8okJ03WoQnE4dXEk=";
2324
sparseCheckout = [ "radicle-httpd" ];
2425
};
26+
2527
sourceRoot = "${src.name}/radicle-httpd";
2628
cargoHash = "sha256-M4tDtUXS99/Zb1Z71CTdW9gMgRR30rbwA6wK7nlwblQ=";
2729

0 commit comments

Comments
 (0)