feat: initial flake with running server

This commit is contained in:
Ashhhleyyy 2024-03-31 23:16:34 +01:00
parent 13cd1f5409
commit 31c89a6808
Signed by: ash
GPG key ID: 83B789081A0878FB
6 changed files with 216 additions and 1 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake

5
.gitignore vendored
View file

@ -26,4 +26,7 @@ music-tmp/
presenter-build presenter-build
node_modules/ node_modules/
.direnv/
result

61
flake.lock Normal file
View 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
}

61
flake.nix Normal file
View file

@ -0,0 +1,61 @@
{
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;
};
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 = {
default = pkgs.python311Packages.buildPythonApplication {
pname = "bapsicle";
inherit version;
doCheck = false;
propagatedBuildInputs = dependencies pkgs.python311Packages;
src = ./.;
patches = [
./patches/0-setup.py-fixes.patch
];
};
};
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
(python311.withPackages dependencies)
nodejs_20
yarn
ffmpeg_6-full
];
};
});
}

View 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'
+ ],
+ },
)

36
sanic-cors.nix Normal file
View 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; [];
};
}