diff options
author | i-like-noodles <i-like-noodles@users.noreply.github.com> | 2022-09-08 15:19:15 +0200 |
---|---|---|
committer | username <username@terminator> | 2022-09-08 15:19:15 +0200 |
commit | b3b5eced13b0366363af63491fe45b7c03e9c492 (patch) | |
tree | 19bd7c68c54880cd007a7180e6fd97833a1e7991 /pkgs/servers/rmfakecloud | |
parent | 08fe70356e67a9de94eec16b849ef1f09aa8dc30 (diff) |
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.
Diffstat (limited to 'pkgs/servers/rmfakecloud')
-rw-r--r-- | pkgs/servers/rmfakecloud/default.nix | 10 | ||||
-rw-r--r-- | pkgs/servers/rmfakecloud/webui.nix | 37 |
2 files changed, 44 insertions, 3 deletions
diff --git a/pkgs/servers/rmfakecloud/default.nix b/pkgs/servers/rmfakecloud/default.nix index db4b335e666f5..4b84ca3e3567f 100644 --- a/pkgs/servers/rmfakecloud/default.nix +++ b/pkgs/servers/rmfakecloud/default.nix @@ -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 ''; diff --git a/pkgs/servers/rmfakecloud/webui.nix b/pkgs/servers/rmfakecloud/webui.nix new file mode 100644 index 0000000000000..8b636baec1159 --- /dev/null +++ b/pkgs/servers/rmfakecloud/webui.nix @@ -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; + }; +} |