feat: package WebStudio/presenter

This commit is contained in:
Ashhhleyyy 2024-04-01 01:16:39 +01:00
parent 31c89a6808
commit ae487a9a40
Signed by: ash
GPG key ID: 83B789081A0878FB
3 changed files with 75 additions and 1 deletions

View file

@ -14,6 +14,9 @@
inherit (pkgs) lib; inherit (pkgs) lib;
inherit (pkgs.python311Packages) setuptools packaging sanic buildPythonPackage fetchPypi; inherit (pkgs.python311Packages) setuptools packaging sanic buildPythonPackage fetchPypi;
}; };
webstudio = import ./webstudio.nix {
inherit pkgs;
};
dependencies = ps: with ps; [ dependencies = ps: with ps; [
setuptools setuptools
wheel wheel
@ -36,7 +39,7 @@
version = self.shortRev or self.dirtyShortRev or "dirty-inputs"; version = self.shortRev or self.dirtyShortRev or "dirty-inputs";
in in
{ {
packages = { packages = rec {
default = pkgs.python311Packages.buildPythonApplication { default = pkgs.python311Packages.buildPythonApplication {
pname = "bapsicle"; pname = "bapsicle";
inherit version; inherit version;
@ -45,8 +48,14 @@
src = ./.; src = ./.;
patches = [ patches = [
./patches/0-setup.py-fixes.patch ./patches/0-setup.py-fixes.patch
(pkgs.substituteAll {
src = ./patches/1-presenter-build-path.patch;
baps_presenter = "${webstudio}";
})
]; ];
}; };
inherit webstudio;
}; };
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {

View file

@ -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",
)

47
webstudio.nix Normal file
View file

@ -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;
}