about summary refs log tree commit diff
path: root/third_party/radicle-explorer/default.nix
blob: 7fe9539ddf74bed33ff22b54b320db23262e7678 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# radicle-explorer is the web UI for Radicle.
#
# They have an upstream Nix derivation, but it only works with experimental
# features Nix and is quite messy, so this is a copy of the relevant parts.
{ pkgs, ... }:

let
  twemoji-assets = pkgs.fetchFromGitHub {
    owner = "twitter";
    repo = "twemoji";
    rev = "v14.0.2";
    hash = "sha256-YoOnZ5uVukzi/6bLi22Y8U5TpplPzB7ji42l+/ys5xI=";
  };

  httpdSrc = pkgs.radicle-httpd.src;
in
pkgs.buildNpmPackage rec {
  pname = "radicle-explorer";
  version = (builtins.fromJSON (builtins.readFile "${src}/package.json")).version;

  # source should be synced with the httpd, which is already in nixpkgs
  src = pkgs.fetchgit {
    inherit (httpdSrc) url rev;
    hash = "sha256:09m13238h6j7g02r6332ihgyyzbjx90pgz14rz29pgv7936h6il8";
  };

  # This might change during nixpkgs bumps and will need updating. Need to fix
  # upstream so that there is a normal, callable derivation.
  npmDepsHash = "sha256:0kw6rvqm0s21j1rss35idvgcrzzczfy6qi3323y385djw4ygk5xs";

  postPatch = ''
    patchShebangs --build ./scripts
    mkdir -p "public/twemoji"
    cp -t public/twemoji -r -- ${twemoji-assets}/assets/svg/*
    : >scripts/install-twemoji-assets
  '';
  dontConfigure = true;
  doCheck = false;

  installPhase = ''
    runHook preInstall
    mkdir -p "$out"
    cp -r -t "$out" build/*
    runHook postInstall
  '';

}