]> Git — Sourcephile - julm/julm-nix.git/blob - nixpkgs/by-name/ra/radicle-explorer/package.nix
nix: update nixos-24.05
[julm/julm-nix.git] / nixpkgs / by-name / ra / radicle-explorer / package.nix
1 { radicle-httpd
2 , fetchFromGitHub
3 , fetchgit
4 , lib
5 , buildNpmPackage
6 , writeText
7 , jq
8 , runCommand
9 ,
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 (
72 self:
73 lib.makeOverridable (
74 { npmDepsHash ? "sha256:0kw6rvqm0s21j1rss35idvgcrzzczfy6qi3323y385djw4ygk5xs"
75 , patches ? [ ]
76 ,
77 }@args:
78 buildNpmPackage {
79 pname = "radicle-explorer";
80 version = radicle-httpd.version;
81 inherit patches npmDepsHash;
82
83 # radicle-explorer uses the radicle-httpd API, and they are developed in the
84 # same repo. For this reason we pin the sources to each other, but due to
85 # radicle-httpd using a more limited sparse checkout we need to carry a
86 # separate hash.
87 src = fetchgit {
88 inherit (radicle-httpd.src) url rev;
89 hash = "sha256:09m13238h6j7g02r6332ihgyyzbjx90pgz14rz29pgv7936h6il8";
90 };
91
92 postPatch = ''
93 patchShebangs --build ./scripts
94 mkdir -p "public/twemoji"
95 cp -t public/twemoji -r -- ${twemojiAssets}/assets/svg/*
96 : >scripts/install-twemoji-assets
97 '';
98
99 dontConfigure = true;
100 doCheck = false;
101
102 installPhase = ''
103 runHook preInstall
104 mkdir -p "$out"
105 cp -r -t "$out" build/*
106 runHook postInstall
107 '';
108
109 passthru = mkPassthru self args;
110
111 meta = {
112 description = "Web frontend for Radicle";
113 longDescription = ''
114 Radicle Explorer is a web-frontend for Radicle which supports browsing
115 repositories, issues and patches on publicly available Radicle seeds.
116
117 This package builds the web interface, ready to be served by any web
118 server.
119 '';
120
121 homepage = "https://radicle.xyz";
122 license = lib.licenses.gpl3;
123
124 maintainers = with lib.maintainers; [
125 tazjin
126 lorenzleutgeb
127 ];
128 };
129 }
130 )
131 )
132 { }