Skip to content

Commit b88b236

Browse files
committed
feat: package WebStudio/presenter
1 parent 85756bf commit b88b236

File tree

3 files changed

+75
-1
lines changed

3 files changed

+75
-1
lines changed

flake.nix

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
inherit (pkgs) lib;
1515
inherit (pkgs.python311Packages) setuptools packaging sanic buildPythonPackage fetchPypi;
1616
};
17+
webstudio = import ./webstudio.nix {
18+
inherit pkgs;
19+
};
1720
dependencies = ps: with ps; [
1821
setuptools
1922
wheel
@@ -36,7 +39,7 @@
3639
version = self.shortRev or self.dirtyShortRev or "dirty-inputs";
3740
in
3841
{
39-
packages = {
42+
packages = rec {
4043
default = pkgs.python311Packages.buildPythonApplication {
4144
pname = "bapsicle";
4245
inherit version;
@@ -45,8 +48,14 @@
4548
src = ./.;
4649
patches = [
4750
./patches/0-setup.py-fixes.patch
51+
(pkgs.substituteAll {
52+
src = ./patches/1-presenter-build-path.patch;
53+
baps_presenter = "${webstudio}";
54+
})
4855
];
4956
};
57+
58+
inherit webstudio;
5059
};
5160

5261
devShells.default = pkgs.mkShell {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
diff --git a/web_server.py b/web_server.py
2+
index ccc3979..dc36db3 100644
3+
--- a/web_server.py
4+
+++ b/web_server.py
5+
@@ -449,11 +449,11 @@ app.static(
6+
app.static("/static", resolve_local_file_path("ui-static"), name="ui-static")
7+
8+
9+
-dist_directory = resolve_local_file_path("presenter-build")
10+
+dist_directory = "@baps_presenter@";
11+
app.static("/presenter", dist_directory)
12+
app.static(
13+
"/presenter/",
14+
- resolve_local_file_path("presenter-build/index.html"),
15+
+ "@baps_presenter@/index.html",
16+
strict_slashes=True,
17+
name="presenter-index",
18+
)

webstudio.nix

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{ pkgs }:
2+
let
3+
src = pkgs.fetchFromGitHub {
4+
owner = "UniversityRadioYork";
5+
repo = "WebStudio";
6+
rev= "8b7f59cdc6ed80b525b2dff665308d808a526d97";
7+
hash = "sha256-I+N/mskX8/gN065SqPxmOn3nrHKPWPcIZygSGbB6GEE=";
8+
};
9+
yarnOfflineCache = pkgs.fetchYarnDeps {
10+
yarnLock = "${src}/yarn.lock";
11+
hash = "sha256-AmKui+Sqyipy4/9lcg8vGWfp9lM2+/fHHDzEWoG8fqw=";
12+
};
13+
in
14+
pkgs.stdenv.mkDerivation {
15+
pname = "baps-presenter";
16+
name = "baps-presenter";
17+
inherit src;
18+
19+
nativeBuildInputs = with pkgs; [
20+
nodejs
21+
yarn
22+
yarn2nix-moretea.fixup_yarn_lock
23+
];
24+
25+
configurePhase = ''
26+
export HOME=$(mktemp -d)
27+
'';
28+
29+
buildPhase = ''
30+
yarn config --offline set yarn-offline-mirror ${yarnOfflineCache}
31+
fixup_yarn_lock yarn.lock
32+
yarn install --offline \
33+
--frozen-lockfile \
34+
--ignore-engines \
35+
--ignore-scripts
36+
patchShebangs .
37+
38+
yarn run build-baps
39+
'';
40+
41+
installPhase = ''
42+
mkdir -p $out
43+
cp -R build/. $out
44+
'';
45+
46+
doDist = false;
47+
}

0 commit comments

Comments
 (0)