nix updates

main
Adrian Gunnar Lauterer 2024-03-24 03:38:24 +01:00
parent 9e6869c68d
commit a5b7198beb
Signed by: adriangl
GPG Key ID: D33368A59745C2F0
4 changed files with 52 additions and 9 deletions

View File

@ -7,17 +7,19 @@
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
lib = forAllSystems (system: nixpkgs.legacyPackages.${system}).lib;
types = forAllSystems (system: nixpkgs.legacyPackages.${system}).types;
types = forAllSystems (system: nixpkgs.legacyPackages.${system}).lib.types;
in
{
packages = forAllSystems (system: let
packages = forAllSystems (system:
let
python = pkgs.${system}.python3.withPackages (ps: [ps.flask ps.flask-socketio]);
ozaiWebui = import ./default.nix { inherit (pkgs.${system}) pkgs; };
in {
default = ozaiWebui;
});
devShells = forAllSystems (system: let
devShells = forAllSystems (system:
let
python = pkgs.${system}.python3.withPackages (ps: [ps.flask ps.flask-socketio]);
in {
default = pkgs.${system}.mkShellNoCC {
@ -29,6 +31,8 @@
nixosModules = forAllSystems (system: let
ozaiWebui = import ./default.nix { inherit (pkgs.${system}) pkgs; };
lib = pkgs.${system}.lib;
types = pkgs.${system}.lib.types;
in {
ozai-webui = { config, pkgs, ... }: {
options.services.ozai-webui = {
@ -60,7 +64,7 @@
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${ozaiWebui}/bin/ozai-webui --port ${toString config.services.ozai-webui.port} --host '${config.services.ozai-webui.host}' --ozai_url '${config.services.ozai-webui.ozaiUrl}' --secret_key '${config.services.ozai-webui.secretKey}'";
ExecStart = "${ozaiWebui}/bin/ozai-webui --port ${toString config.services.ozai-webui.port} --host '${config.services.ozai-webui.host}' --ozai_url '${config.services.ozai-webui.ozaiUrl}' --secret_key '${config.services.ozai-webui.secretKey}' --static_folder '/share/ozai-webui/static' --template_folder '/share/ozai-webui/templates'";
Restart = "always";
};
};
@ -68,6 +72,34 @@
};
});
nixosConfigurations = {
ozai-webui = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
self.nixosModules.x86_64-linux.ozai-webui
{
system.stateVersion = "23.11";
boot.isContainer = true;
services.ozai-webui.enable = true;
}
];
};
};
# nixosConfigurations = forAllSystems (system: {
# ozai-webui = { config, pkgs, ... }: {
# modules = [
# self.systems.${system}.nixosModules.ozai-webui
# {
# system.stateVersion = "23.11";
# boot.isContainer = true;
# services.ozai-webui.enable = true;
# }
# ];
# };
# });
};

View File

@ -9,8 +9,9 @@ buildPythonApplication rec {
#copy the static files to the output
postInstall = ''
cp -r static $out/bin/static
cp -r templates $out/bin/templates
mkdir -p $out/share/ozai-webui
cp -r static $out/share/ozai-webui/static
cp -r templates $out/share/ozai-webui/templates
mv $out/bin/main.py $out/bin/ozai-webui
'';
}

View File

@ -12,6 +12,8 @@ ozai_url = 'http://localhost:8000/api/'
ozai_webui_host = '0.0.0.0'
ozai_webui_port = 5000
app.config['SECRET_KEY'] = "secret"
static_folder = 'static'
template_folder = 'templates'
#check if the environment variables are set
if os.getenv('OZAI_URL') is not None:
@ -22,6 +24,10 @@ if os.getenv('OZAI_WEBUI_PORT') is not None:
ozai_webui_port = int(os.getenv('OZAI_WEBUI_PORT'))
if os.getenv('OZAI_WEBUI_SECRET_KEY') is not None:
app.config['SECRET_KEY'] = os.getenv('OZAI_WEBUI_SECRET_KEY')
if os.getenv('OZAI_WEBUI_STATIC_FOLDER') is not None:
static_folder = os.getenv('STATIC_FOLDER')
if os.getenv('OZAI_WEBUI_TEMPLATE_FOLDER') is not None:
template_folder = os.getenv('TEMPLATE_FOLDER')
parser = argparse.ArgumentParser(description="Run the Ozai WebUI server")
@ -29,6 +35,9 @@ parser.add_argument('-H', '--host', type=str, default=ozai_webui_host, help='The
parser.add_argument('-P', '--port', type=int, default=ozai_webui_port, help='The port to run the server on')
parser.add_argument('-O', '--ozai_url', type=str, default=ozai_url, help='The URL of the Ozai server')
parser.add_argument('-S', '--secret_key', type=str, default=app.config['SECRET_KEY'], help='The secret key for the Flask app')
parser.add_argument('--static_folder', type=str, default=static_folder, help='The location of the static folder')
parser.add_argument('--template_folder', type=str, default=template_folder, help='The location of the template folder')
args = parser.parse_args()
@ -40,8 +49,10 @@ if args.ozai_url:
ozai_url = args.ozai_url
if args.secret_key:
app.config['SECRET_KEY'] = args.secret_key
if args.static_folder:
app.static_folder = args.static_folder
if args.template_folder:
app.template_folder = args.template_folder
#home page

View File

@ -11,7 +11,6 @@ requires = (
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
setup(
name='ozai-webui',
version='0.1.1',