diff --git a/flake.nix b/flake.nix index 53a25c1..7f3f6cd 100644 --- a/flake.nix +++ b/flake.nix @@ -17,6 +17,24 @@ webstudio = import ./webstudio.nix { inherit pkgs; }; + ui-templates = pkgs.stdenv.mkDerivation { + name = "baps-ui-templates"; + src = ./ui-templates; + phases = "installPhase"; + installPhase = '' + mkdir -p $out + cp -R $src/. $out + ''; + }; + ui-static = pkgs.stdenv.mkDerivation { + name = "baps-ui-static"; + src = ./ui-static; + phases = "installPhase"; + installPhase = '' + mkdir -p $out + cp -R $src/. $out + ''; + }; dependencies = ps: with ps; [ setuptools wheel @@ -51,6 +69,8 @@ (pkgs.substituteAll { src = ./patches/1-presenter-build-path.patch; baps_presenter = "${webstudio}"; + ui_static = "${ui-static}"; + ui_templates = "${ui-templates}"; }) ]; }; diff --git a/patches/1-presenter-build-path.patch b/patches/1-presenter-build-path.patch index 2be7603..3398d0c 100644 --- a/patches/1-presenter-build-path.patch +++ b/patches/1-presenter-build-path.patch @@ -1,9 +1,25 @@ diff --git a/web_server.py b/web_server.py -index ccc3979..dc36db3 100644 +index ccc3979..2909ff8 100644 --- a/web_server.py +++ b/web_server.py -@@ -449,11 +449,11 @@ app.static( - app.static("/static", resolve_local_file_path("ui-static"), name="ui-static") +@@ -32,7 +32,7 @@ import package + from baps_types.happytime import happytime + + env = Environment( +- loader=FileSystemLoader("%s/ui-templates/" % os.path.dirname(__file__)), ++ loader=FileSystemLoader("@ui_templates@"), + autoescape=select_autoescape(), + ) + +@@ -444,16 +444,16 @@ async def audio_file(request, type: str, id: int): + + # Static Files + app.static( +- "/favicon.ico", resolve_local_file_path("ui-static/favicon.ico"), name="ui-favicon" ++ "/favicon.ico", "@ui_static@/favicon.ico", name="ui-favicon" + ) +-app.static("/static", resolve_local_file_path("ui-static"), name="ui-static") ++app.static("/static", "@ui_static@", name="ui-static") -dist_directory = resolve_local_file_path("presenter-build") diff --git a/webstudio.nix b/webstudio.nix index df1b6ec..78b2a1a 100644 --- a/webstudio.nix +++ b/webstudio.nix @@ -12,7 +12,6 @@ let }; in pkgs.stdenv.mkDerivation { - pname = "baps-presenter"; name = "baps-presenter"; inherit src;