Skip to content

Commit 475e1d0

Browse files
committed
feat: package server ui
1 parent b88b236 commit 475e1d0

File tree

3 files changed

+39
-4
lines changed

3 files changed

+39
-4
lines changed

flake.nix

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,24 @@
1717
webstudio = import ./webstudio.nix {
1818
inherit pkgs;
1919
};
20+
ui-templates = pkgs.stdenv.mkDerivation {
21+
name = "baps-ui-templates";
22+
src = ./ui-templates;
23+
phases = "installPhase";
24+
installPhase = ''
25+
mkdir -p $out
26+
cp -R $src/. $out
27+
'';
28+
};
29+
ui-static = pkgs.stdenv.mkDerivation {
30+
name = "baps-ui-static";
31+
src = ./ui-static;
32+
phases = "installPhase";
33+
installPhase = ''
34+
mkdir -p $out
35+
cp -R $src/. $out
36+
'';
37+
};
2038
dependencies = ps: with ps; [
2139
setuptools
2240
wheel
@@ -51,6 +69,8 @@
5169
(pkgs.substituteAll {
5270
src = ./patches/1-presenter-build-path.patch;
5371
baps_presenter = "${webstudio}";
72+
ui_static = "${ui-static}";
73+
ui_templates = "${ui-templates}";
5474
})
5575
];
5676
};

patches/1-presenter-build-path.patch

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
diff --git a/web_server.py b/web_server.py
2-
index ccc3979..dc36db3 100644
2+
index ccc3979..2909ff8 100644
33
--- a/web_server.py
44
+++ b/web_server.py
5-
@@ -449,11 +449,11 @@ app.static(
6-
app.static("/static", resolve_local_file_path("ui-static"), name="ui-static")
5+
@@ -32,7 +32,7 @@ import package
6+
from baps_types.happytime import happytime
7+
8+
env = Environment(
9+
- loader=FileSystemLoader("%s/ui-templates/" % os.path.dirname(__file__)),
10+
+ loader=FileSystemLoader("@ui_templates@"),
11+
autoescape=select_autoescape(),
12+
)
13+
14+
@@ -444,16 +444,16 @@ async def audio_file(request, type: str, id: int):
15+
16+
# Static Files
17+
app.static(
18+
- "/favicon.ico", resolve_local_file_path("ui-static/favicon.ico"), name="ui-favicon"
19+
+ "/favicon.ico", "@ui_static@/favicon.ico", name="ui-favicon"
20+
)
21+
-app.static("/static", resolve_local_file_path("ui-static"), name="ui-static")
22+
+app.static("/static", "@ui_static@", name="ui-static")
723

824

925
-dist_directory = resolve_local_file_path("presenter-build")

webstudio.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ let
1212
};
1313
in
1414
pkgs.stdenv.mkDerivation {
15-
pname = "baps-presenter";
1615
name = "baps-presenter";
1716
inherit src;
1817

0 commit comments

Comments
 (0)