mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-10-18 19:30:27 +08:00
Add a flake to build the web frontend
Includes the twemoji assets and a check output that runs all tests except e2e. Updates to test/support/heartwood-version must also be reflected in flake.nix in inputs.heartwood.url.
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
{
|
||||
description = "Radicle web frontend";
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/release-23.11";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
heartwood = {
|
||||
inputs.flake-utils.follows = "flake-utils";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
url = "git+https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5.git?ref=master&rev=49584f4e732fb0039d2089f3c39fd56fc34a2ee3";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
heartwood,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
...
|
||||
}@inputs:
|
||||
{
|
||||
nixosModules.radicle-interface = { config, lib, pkgs, ... }: {
|
||||
options.services.radicle-interface.enable = lib.mkEnableOption "Local radicle web interface";
|
||||
config = lib.mkIf config.services.radicle-interface.enable {
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
virtualHosts.localhost = {
|
||||
listen = [ { addr = "127.0.0.1"; port = 4433; ssl = false; } ];
|
||||
rejectSSL = true;
|
||||
locations = {
|
||||
"/" = {
|
||||
index = "index.html";
|
||||
root = self.packages.${pkgs.system}.radicle-interface;
|
||||
extraConfig = ''
|
||||
try_files $uri $uri/ /index.html;
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
} //
|
||||
|
||||
(flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
inherit (pkgs) lib;
|
||||
in {
|
||||
|
||||
checks = {
|
||||
radicle-interface = self.packages.${system}.radicle-interface.override { doCheck = true; };
|
||||
};
|
||||
|
||||
packages = {
|
||||
default = self.packages.${system}.radicle-interface;
|
||||
twemoji-assets = pkgs.fetchFromGitHub {
|
||||
owner = "twitter";
|
||||
repo = "twemoji";
|
||||
rev = "v14.0.2";
|
||||
hash = "sha256-YoOnZ5uVukzi/6bLi22Y8U5TpplPzB7ji42l+/ys5xI=";
|
||||
};
|
||||
|
||||
radicle-interface = pkgs.callPackage ({
|
||||
lib, buildNpmPackage, doCheck ? false
|
||||
}: let
|
||||
# We need rad debug binaries
|
||||
devProfile = _: { CARGO_PROFILE = ""; };
|
||||
checkBins = pkgs.buildEnv {
|
||||
name = "heartwood-debug-bins";
|
||||
paths = with heartwood.packages.${system}; [
|
||||
(default.overrideAttrs devProfile)
|
||||
(radicle-httpd.overrideAttrs devProfile)
|
||||
];
|
||||
};
|
||||
in buildNpmPackage rec {
|
||||
pname = "radicle-interface";
|
||||
version = "1.0.0";
|
||||
src = ./.;
|
||||
npmDepsHash = "sha256-WBX+S67Y7SnXLfc202eNxM355Q0nTH4G7fMY5eEDIio=";
|
||||
postPatch = ''
|
||||
patchShebangs --build ./scripts
|
||||
mkdir -p "public/twemoji"
|
||||
cp -t public/twemoji -r -- ${self.packages.${system}.twemoji-assets}/assets/svg/*
|
||||
: >scripts/install-twemoji-assets
|
||||
'';
|
||||
dontConfigure = true;
|
||||
|
||||
inherit doCheck;
|
||||
nativeCheckInputs = with pkgs; [
|
||||
which
|
||||
gitMinimal
|
||||
];
|
||||
checkPhase = ''
|
||||
runHook preCheck
|
||||
heartwoodRev="${heartwood.rev or "unknown"}"
|
||||
expRev=$(cat tests/support/heartwood-version)
|
||||
if [ "''${heartwoodRev#$expRev}" = "$heartwoodRev" ]; then
|
||||
printf "Error: Expecting heartwood binaries revision '%s', got '%s'" "$expRev" "$heartwoodRev" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo unknown > tests/support/heartwood-version
|
||||
scripts/install-binaries -l ${checkBins}/bin
|
||||
scripts/check
|
||||
{
|
||||
npm run test:unit
|
||||
npm run test:httpd-api:unit
|
||||
} | tee /dev/null
|
||||
runHook postCheck
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mkdir -p "$out"
|
||||
cp -r -t "$out" build/*
|
||||
runHook postInstall
|
||||
'';
|
||||
}) {};
|
||||
};
|
||||
}));
|
||||
}
|
||||
Reference in New Issue
Block a user