diff --git a/flake.nix b/flake.nix index b67709f..53a25c1 100644 --- a/flake.nix +++ b/flake.nix @@ -14,6 +14,9 @@ inherit (pkgs) lib; inherit (pkgs.python311Packages) setuptools packaging sanic buildPythonPackage fetchPypi; }; + webstudio = import ./webstudio.nix { + inherit pkgs; + }; dependencies = ps: with ps; [ setuptools wheel @@ -36,7 +39,7 @@ version = self.shortRev or self.dirtyShortRev or "dirty-inputs"; in { - packages = { + packages = rec { default = pkgs.python311Packages.buildPythonApplication { pname = "bapsicle"; inherit version; @@ -45,8 +48,14 @@ src = ./.; patches = [ ./patches/0-setup.py-fixes.patch + (pkgs.substituteAll { + src = ./patches/1-presenter-build-path.patch; + baps_presenter = "${webstudio}"; + }) ]; }; + + inherit webstudio; }; devShells.default = pkgs.mkShell { diff --git a/patches/1-presenter-build-path.patch b/patches/1-presenter-build-path.patch new file mode 100644 index 0000000..2be7603 --- /dev/null +++ b/patches/1-presenter-build-path.patch @@ -0,0 +1,18 @@ +diff --git a/web_server.py b/web_server.py +index ccc3979..dc36db3 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") + + +-dist_directory = resolve_local_file_path("presenter-build") ++dist_directory = "@baps_presenter@"; + app.static("/presenter", dist_directory) + app.static( + "/presenter/", +- resolve_local_file_path("presenter-build/index.html"), ++ "@baps_presenter@/index.html", + strict_slashes=True, + name="presenter-index", + ) diff --git a/webstudio.nix b/webstudio.nix new file mode 100644 index 0000000..df1b6ec --- /dev/null +++ b/webstudio.nix @@ -0,0 +1,47 @@ +{ pkgs }: +let + src = pkgs.fetchFromGitHub { + owner = "UniversityRadioYork"; + repo = "WebStudio"; + rev= "8b7f59cdc6ed80b525b2dff665308d808a526d97"; + hash = "sha256-I+N/mskX8/gN065SqPxmOn3nrHKPWPcIZygSGbB6GEE="; + }; + yarnOfflineCache = pkgs.fetchYarnDeps { + yarnLock = "${src}/yarn.lock"; + hash = "sha256-AmKui+Sqyipy4/9lcg8vGWfp9lM2+/fHHDzEWoG8fqw="; + }; +in +pkgs.stdenv.mkDerivation { + pname = "baps-presenter"; + name = "baps-presenter"; + inherit src; + + nativeBuildInputs = with pkgs; [ + nodejs + yarn + yarn2nix-moretea.fixup_yarn_lock + ]; + + configurePhase = '' + export HOME=$(mktemp -d) + ''; + + buildPhase = '' + yarn config --offline set yarn-offline-mirror ${yarnOfflineCache} + fixup_yarn_lock yarn.lock + yarn install --offline \ + --frozen-lockfile \ + --ignore-engines \ + --ignore-scripts + patchShebangs . + + yarn run build-baps + ''; + + installPhase = '' + mkdir -p $out + cp -R build/. $out + ''; + + doDist = false; +}