Skip to content

Commit de4a766

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 1182bd0 commit de4a766

File tree

2 files changed

+29
-58
lines changed

2 files changed

+29
-58
lines changed

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

+29-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,33 @@ 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+
# use env because of https://github.com/NixOS/nixpkgs/issues/358844
26+
env.pnpmRoot = "ui";
27+
env.pnpmDeps = pnpm_9.fetchDeps {
28+
inherit pname version src;
29+
sourceRoot = "${src.name}/ui";
30+
pnpmLock = "${src}/ui/pnpm-lock.yaml";
31+
hash = "sha256-VNmCT4um2W2ii8jAm+KjQSjixYEKoZkw7CeRwErff/o=";
32+
};
33+
preBuild = lib.optionals enableWebui ''
34+
# using sass-embedded fails at executing node_modules/sass-embedded-linux-x64/dart-sass/src/dart
35+
rm -r ui/node_modules/sass-embedded ui/node_modules/.pnpm/sass-embedded*
36+
37+
# avoid re-running pnpm i...
38+
touch ui/pnpm-lock.yaml
39+
40+
make ui/dist
41+
'';
42+
nativeBuildInputs = lib.optionals enableWebui [
43+
nodejs
44+
pnpm_9.configHook
45+
];
46+
47+
# ... or don't embed it in the server
48+
postPatch = lib.optionals (!enableWebui) ''
49+
sed -i '/go:/d' ui/assets.go
50+
'';
3451

3552
ldflags = [
3653
"-s"

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

-46
This file was deleted.

0 commit comments

Comments
 (0)