2024-03-23 17:49:50 +01:00
|
|
|
{
|
2024-05-29 18:43:06 +02:00
|
|
|
description = "Ozai WebUI";
|
2024-03-23 17:49:50 +01:00
|
|
|
|
2024-05-29 18:43:06 +02:00
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
|
|
};
|
2024-03-23 17:49:50 +01:00
|
|
|
|
2024-05-29 18:43:06 +02:00
|
|
|
outputs = { self, nixpkgs, ... }@inputs:
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
|
|
|
lib = pkgs.lib;
|
|
|
|
types = lib.types;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
packages.x86_64-linux.default = pkgs.python3Packages.buildPythonApplication rec {
|
|
|
|
pname = "ozai-webui";
|
|
|
|
version = "0.1.1";
|
|
|
|
propagatedBuildInputs = [ pkgs.python3Packages.flask pkgs.python3Packages.flask-socketio ];
|
|
|
|
src = ./src;
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
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
|
|
|
|
'';
|
|
|
|
};
|
2024-03-23 17:49:50 +01:00
|
|
|
|
2024-05-29 18:43:06 +02:00
|
|
|
nixosModules.ozai-webui = { config, pkgs, ... }: {
|
|
|
|
options.services.ozai-webui = {
|
|
|
|
enable = lib.mkEnableOption "Ozai WebUI";
|
|
|
|
host = lib.mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "127.0.0.1";
|
|
|
|
description = "The host to run the server on";
|
|
|
|
};
|
|
|
|
port = lib.mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 8080;
|
|
|
|
description = "The port to run the server on";
|
|
|
|
};
|
|
|
|
ozaiUrl = lib.mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "http://localhost:8000/api/";
|
|
|
|
description = "The URL of the Ozai server";
|
|
|
|
};
|
|
|
|
secretKey = lib.mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "secret_key";
|
|
|
|
description = "The secret key for the Flask app";
|
|
|
|
};
|
|
|
|
};
|
2024-03-24 00:48:43 +01:00
|
|
|
|
2024-05-29 18:43:06 +02:00
|
|
|
config = lib.mkIf config.services.ozai-webui.enable {
|
|
|
|
systemd.services.ozai-webui = {
|
|
|
|
description = "Ozai WebUI server";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${self.packages.x86_64-linux.default}/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";
|
2024-03-24 03:38:24 +01:00
|
|
|
};
|
|
|
|
};
|
2024-05-29 18:43:06 +02:00
|
|
|
};
|
2024-03-24 00:48:43 +01:00
|
|
|
};
|
2024-05-29 18:43:06 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|