Merge pull request #189639 from i-like-noodles/rmfakecloud-build-ui

rmfakecloud: build the web ui
This commit is contained in:
Christian Kögler 2022-10-14 22:31:57 +02:00 committed by GitHub
commit 7b3766e350
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 3 deletions

View File

@ -1,4 +1,4 @@
{ lib, fetchFromGitHub, buildGoModule }:
{ lib, fetchFromGitHub, buildGoModule, callPackage, enableWebui ? true }:
buildGoModule rec {
pname = "rmfakecloud";
@ -13,8 +13,12 @@ buildGoModule rec {
vendorSha256 = "sha256-NwDaPpjkQogXE37RGS3zEALlp3NuXP9RW//vbwM6y0A=";
postPatch = ''
# skip including the JS SPA, which is difficult to build
ui = callPackage ./webui.nix { inherit version src; };
postPatch = if enableWebui then ''
mkdir -p ui/build
cp -r ${ui}/* ui/build
'' else ''
sed -i '/go:/d' ui/assets.go
'';

View File

@ -0,0 +1,37 @@
{ version, src, stdenv, lib, fetchFromGitHub, fetchYarnDeps, fixup_yarn_lock, yarn, nodejs }:
stdenv.mkDerivation rec {
inherit version src;
pname = "rmfakecloud-webui";
yarnOfflineCache = fetchYarnDeps {
yarnLock = "${src}/ui/yarn.lock";
sha256 = "sha256-lKA3W7gXT2Dnux+sIXCluG5HxkGQgHPnCjgV/a4pjY0=";
};
nativeBuildInputs = [ fixup_yarn_lock yarn nodejs ];
buildPhase = ''
export HOME=$(mktemp -d)
cd ui
fixup_yarn_lock yarn.lock
yarn config --offline set yarn-offline-mirror ${yarnOfflineCache}
yarn install --offline --frozen-lockfile --ignore-engines --ignore-scripts --no-progress
patchShebangs node_modules
export PATH=$PWD/node_modules/.bin:$PATH
./node_modules/.bin/react-scripts build
mkdir -p $out
cd ..
'';
installPhase = ''
cp -r ui/build/* $out
'';
meta = with lib; {
description = "Only the webui files for rmfakecloud";
homepage = "https://ddvk.github.io/rmfakecloud/";
license = licenses.agpl3Only;
};
}