nixpkgs-suyu/pkgs/servers/rmfakecloud/webui.nix
i-like-noodles b3b5eced13 rmfakecloud: build the web ui
Previously rmfakecloud was built without the web ui making it show 404 when attempting to use it. Build it similar to how other projects using yarn are built in a separate package and make it optional.
2022-09-08 15:19:15 +02:00

37 lines
1,014 B
Nix

{ 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;
};
}