Compare commits
2 commits
13cd1f5409
...
ae487a9a40
Author | SHA1 | Date | |
---|---|---|---|
ae487a9a40 | |||
31c89a6808 |
8 changed files with 290 additions and 1 deletions
1
.envrc
Normal file
1
.envrc
Normal file
|
@ -0,0 +1 @@
|
|||
use flake
|
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -26,4 +26,7 @@ music-tmp/
|
|||
|
||||
presenter-build
|
||||
|
||||
node_modules/
|
||||
node_modules/
|
||||
|
||||
.direnv/
|
||||
result
|
||||
|
|
61
flake.lock
Normal file
61
flake.lock
Normal file
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1711715736,
|
||||
"narHash": "sha256-9slQ609YqT9bT/MNX9+5k5jltL9zgpn36DpFB7TkttM=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "807c549feabce7eddbf259dbdcec9e0600a0660d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
70
flake.nix
Normal file
70
flake.nix
Normal file
|
@ -0,0 +1,70 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = github:NixOS/nixpkgs/nixpkgs-unstable;
|
||||
flake-utils.url = github:numtide/flake-utils;
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
};
|
||||
sanic-cors = import ./sanic-cors.nix {
|
||||
inherit (pkgs) lib;
|
||||
inherit (pkgs.python311Packages) setuptools packaging sanic buildPythonPackage fetchPypi;
|
||||
};
|
||||
webstudio = import ./webstudio.nix {
|
||||
inherit pkgs;
|
||||
};
|
||||
dependencies = ps: with ps; [
|
||||
setuptools
|
||||
wheel
|
||||
sanic
|
||||
sanic-cors
|
||||
pygame
|
||||
syncer
|
||||
aiohttp
|
||||
mutagen
|
||||
sounddevice
|
||||
setproctitle
|
||||
pyttsx3
|
||||
websockets
|
||||
pyserial
|
||||
requests
|
||||
jinja2
|
||||
pydub
|
||||
psutil
|
||||
];
|
||||
version = self.shortRev or self.dirtyShortRev or "dirty-inputs";
|
||||
in
|
||||
{
|
||||
packages = rec {
|
||||
default = pkgs.python311Packages.buildPythonApplication {
|
||||
pname = "bapsicle";
|
||||
inherit version;
|
||||
doCheck = false;
|
||||
propagatedBuildInputs = dependencies pkgs.python311Packages;
|
||||
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 {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
(python311.withPackages dependencies)
|
||||
nodejs_20
|
||||
yarn
|
||||
ffmpeg_6-full
|
||||
];
|
||||
};
|
||||
});
|
||||
}
|
53
patches/0-setup.py-fixes.patch
Normal file
53
patches/0-setup.py-fixes.patch
Normal file
|
@ -0,0 +1,53 @@
|
|||
diff --git a/launch.py b/launch.py
|
||||
index 712bb6a..6210095 100755
|
||||
--- a/launch.py
|
||||
+++ b/launch.py
|
||||
@@ -54,14 +54,7 @@ def notif(msg: str):
|
||||
print("NOTIFICATION:{}".format(msg))
|
||||
|
||||
|
||||
-if __name__ == "__main__":
|
||||
- # On Windows, calling this function is necessary.
|
||||
- # Causes all kinds of loops if not present.
|
||||
- # IT HAS TO BE RIGHT HERE, AT THE TOP OF __MAIN__
|
||||
- # NOT INSIDE AN IF STATEMENT. RIGHT. HERE.
|
||||
- # If it's not here, multiprocessing just doesn't run in the package.
|
||||
- # Freeze support refers to being packaged with Pyinstaller.
|
||||
- multiprocessing.freeze_support()
|
||||
+def main():
|
||||
setproctitle("BAPSicle - Launcher")
|
||||
if len(sys.argv) > 1:
|
||||
# We got an argument! It's probably Platypus's UI.
|
||||
@@ -86,3 +79,13 @@ if __name__ == "__main__":
|
||||
else:
|
||||
startServer()
|
||||
sys.exit(0)
|
||||
+
|
||||
+if __name__ == "__main__":
|
||||
+ # On Windows, calling this function is necessary.
|
||||
+ # Causes all kinds of loops if not present.
|
||||
+ # IT HAS TO BE RIGHT HERE, AT THE TOP OF __MAIN__
|
||||
+ # NOT INSIDE AN IF STATEMENT. RIGHT. HERE.
|
||||
+ # If it's not here, multiprocessing just doesn't run in the package.
|
||||
+ # Freeze support refers to being packaged with Pyinstaller.
|
||||
+ multiprocessing.freeze_support()
|
||||
+ main()
|
||||
diff --git a/setup.py b/setup.py
|
||||
index 9af4e1d..3a6db65 100644
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -7,5 +7,13 @@ setup(
|
||||
description=package.DESCRIPTION,
|
||||
author=package.AUTHOR,
|
||||
license=package.LICENSE,
|
||||
- packages=find_packages(),
|
||||
+ packages=find_packages() + [
|
||||
+ '.',
|
||||
+ 'alerts',
|
||||
+ ],
|
||||
+ entry_points={
|
||||
+ 'console_scripts': [
|
||||
+ 'bapsicle = launch:main'
|
||||
+ ],
|
||||
+ },
|
||||
)
|
18
patches/1-presenter-build-path.patch
Normal file
18
patches/1-presenter-build-path.patch
Normal 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",
|
||||
)
|
36
sanic-cors.nix
Normal file
36
sanic-cors.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{ lib
|
||||
, buildPythonPackage
|
||||
, fetchPypi
|
||||
|
||||
, setuptools
|
||||
, packaging
|
||||
, sanic
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
pname = "Sanic-Cors";
|
||||
version = "2.2.0";
|
||||
pyproject= true;
|
||||
|
||||
src = fetchPypi {
|
||||
inherit pname version;
|
||||
hash = "sha256-+NdRXaTIuDeHHUIsZjFMS1cEOWp4iUtZxQ4mqnKpWHM=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
setuptools
|
||||
];
|
||||
|
||||
propagatedBuildInputs = [
|
||||
sanic
|
||||
packaging
|
||||
];
|
||||
|
||||
meta = with lib; {
|
||||
changelog = "https://github.com/ashleysommer/sanic-cors/releases/tag/${version}";
|
||||
description = "A Sanic extension for handling Cross Origin Resource Sharing (CORS), making cross-origin AJAX possible.";
|
||||
homepage = "https://github.com/ashleysommer/sanic-cors";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [];
|
||||
};
|
||||
}
|
47
webstudio.nix
Normal file
47
webstudio.nix
Normal 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;
|
||||
}
|
Loading…
Reference in a new issue