Skip to content

Commit d5e1048

Browse files
committed
rmfakecloud: build the webui together with the app
This avoids maintaining an artificial derivation for the web UI, and hopefully will allow the auto-update bot to make PRs for further updates
1 parent 8a43018 commit d5e1048

File tree

2 files changed

+28
-58
lines changed

2 files changed

+28
-58
lines changed

pkgs/by-name/rm/rmfakecloud/package.nix

+28-12
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
lib,
33
fetchFromGitHub,
44
buildGoModule,
5-
callPackage,
65
enableWebui ? true,
6+
pnpm_9,
7+
nodejs,
78
nixosTests,
89
}:
910

@@ -20,17 +21,32 @@ buildGoModule rec {
2021

2122
vendorHash = "sha256-9tfxE03brUvCYusmewiqNpCkKyIS9qePqylrzDWrJLY=";
2223

23-
ui = callPackage ./webui.nix { inherit version src; };
24-
25-
postPatch =
26-
if enableWebui then
27-
''
28-
cp -a ${ui} ui/dist
29-
''
30-
else
31-
''
32-
sed -i '/go:/d' ui/assets.go
33-
'';
24+
# if using webUI build it
25+
pnpmRoot = "ui";
26+
pnpmDeps = pnpm_9.fetchDeps {
27+
inherit pname version src;
28+
sourceRoot = "${src.name}/ui";
29+
pnpmLock = "${src}/ui/pnpm-lock.yaml";
30+
hash = "sha256-VNmCT4um2W2ii8jAm+KjQSjixYEKoZkw7CeRwErff/o=";
31+
};
32+
preBuild = lib.optionals enableWebui ''
33+
# using sass-embedded fails at executing node_modules/sass-embedded-linux-x64/dart-sass/src/dart
34+
rm -r ui/node_modules/sass-embedded ui/node_modules/.pnpm/sass-embedded*
35+
36+
# avoid re-running pnpm i...
37+
touch ui/pnpm-lock.yaml
38+
39+
make ui/dist
40+
'';
41+
nativeBuildInputs = lib.optionals enableWebui [
42+
nodejs
43+
pnpm_9.configHook
44+
];
45+
46+
# ... or don't embed it in the server
47+
postPatch = lib.optionals (!enableWebui) ''
48+
sed -i '/go:/d' ui/assets.go
49+
'';
3450

3551
ldflags = [
3652
"-s"

pkgs/by-name/rm/rmfakecloud/webui.nix

-46
This file was deleted.

0 commit comments

Comments
 (0)