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;
|
2024-05-31 18:06:33 +02:00
|
|
|
deps = [
|
|
|
|
pkgs.python3
|
|
|
|
pkgs.python3Packages.flask
|
|
|
|
pkgs.python3Packages.flask-socketio
|
|
|
|
pkgs.python3Packages.requests
|
|
|
|
pkgs.python3Packages.gunicorn
|
|
|
|
pkgs.python3Packages.eventlet
|
|
|
|
];
|
2024-05-29 18:43:06 +02:00
|
|
|
in
|
|
|
|
{
|
2024-05-31 18:06:33 +02:00
|
|
|
packages.x86_64-linux.default = pkgs.python3Packages.buildPythonPackage rec {
|
2024-05-29 18:43:06 +02:00
|
|
|
pname = "ozai-webui";
|
|
|
|
version = "0.1.1";
|
2024-05-31 18:06:33 +02:00
|
|
|
#propagatedBuildInputs = deps;
|
|
|
|
dependencies = deps;
|
2024-05-29 18:43:06 +02:00
|
|
|
src = ./src;
|
|
|
|
doCheck = false;
|
2024-05-31 18:06:33 +02:00
|
|
|
|
2024-05-29 18:43:06 +02:00
|
|
|
postInstall = ''
|
2024-05-31 18:06:33 +02:00
|
|
|
mkdir -p $out/share/ozai_webui/static
|
|
|
|
mkdir -p $out/share/ozai_webui/templates
|
2024-09-08 01:08:58 +02:00
|
|
|
mkdir -p $out/lib/python3.11/site-packages/ozai_webui/templates
|
|
|
|
mkdir -p $out/lib/python3.11/site-packages/ozai_webui/static
|
|
|
|
mkdir -p $out/lib/python3.11/site-packages/templates
|
|
|
|
mkdir -p $out/lib/python3.11/site-packages/static
|
|
|
|
mkdir -p $out/lib/python3.11/templates
|
|
|
|
mkdir -p $out/lib/python3.11/static
|
2024-05-31 18:06:33 +02:00
|
|
|
install -Dm444 ${src}/static/* $out/share/ozai_webui/static/
|
|
|
|
install -Dm444 ${src}/templates/* $out/share/ozai_webui/templates/
|
2024-09-08 01:08:58 +02:00
|
|
|
cp -r $src/templates $out/lib/python3.11/site-packages/ozai_webui/templates
|
|
|
|
cp -r $src/templates $out/lib/python3.11/site-packages/templates
|
|
|
|
cp -r $src/templates $out/lib/python3.11/templates
|
|
|
|
cp -r $src/static $out/lib/python3.11/site-packages/ozai_webui/static
|
|
|
|
cp -r $src/static $out/lib/python3.11/site-packages/static
|
|
|
|
cp -r $src/static $out/lib/python3.11/static
|
|
|
|
chmod -R 444 $out/lib/python3.11
|
2024-05-31 18:06:33 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
packages.x86_64-linux.ozai-webui-run = pkgs.stdenv.mkDerivation rec {
|
|
|
|
pname = "ozai-webui-run";
|
|
|
|
version = "0.1.1";
|
|
|
|
src = ./src;
|
|
|
|
|
|
|
|
pythonEnv = pkgs.python3.withPackages (ps: with ps; [
|
|
|
|
flask
|
|
|
|
flask-socketio
|
|
|
|
requests
|
|
|
|
gunicorn
|
|
|
|
eventlet
|
|
|
|
]);
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
pkgs.bash
|
|
|
|
pythonEnv
|
|
|
|
];
|
|
|
|
|
|
|
|
propagatedBuildInputs = buildInputs;
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
pkgs.makeWrapper
|
|
|
|
];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin
|
2024-09-08 01:05:50 +02:00
|
|
|
mkdir -p $out/share/ozai_webui/static
|
|
|
|
mkdir -p $out/share/ozai_webui/templates
|
|
|
|
mkdir -p $out/bin/templates
|
|
|
|
mkdir -p $out/bin/static
|
2024-05-31 18:06:33 +02:00
|
|
|
cp -r $src/templates $out/bin/templates
|
|
|
|
cp -r $src/static $out/bin/static
|
|
|
|
cp $src/run.sh $out/bin/run
|
|
|
|
chmod +x $out/bin/run
|
|
|
|
wrapProgram $out/bin/run \
|
|
|
|
--prefix PATH : ${lib.makeBinPath buildInputs}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
devShells.x86_64-linux.default = pkgs.mkShell {
|
|
|
|
buildInputs = deps;
|
|
|
|
shellHook = ''
|
|
|
|
OZAI_WEBUI_STATIC_FOLDER=result/share/ozai-webui/static
|
|
|
|
OZAI_WEBUI_TEMPLATE_FOLDER=result/share/ozai-webui/templates
|
2024-05-29 18:43:06 +02:00
|
|
|
'';
|
|
|
|
};
|
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";
|
|
|
|
};
|
|
|
|
};
|
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" ];
|
2024-05-31 18:06:33 +02:00
|
|
|
environment = {
|
|
|
|
OZAI_URL= "${config.services.ozai-webui.ozaiUrl}";
|
|
|
|
OZAI_WEBUI_HOST= "${config.services.ozai-webui.host}";
|
|
|
|
OZAI_WEBUI_PORT= toString(config.services.ozai-webui.port);
|
|
|
|
OZAI_WEBUI_STATIC_FOLDER= "${self.packages.x86_64-linux.default}/share/ozai-webui/static";
|
|
|
|
OZAI_WEBUI_TEMPLATE_FOLDER="${self.packages.x86_64-linux.default}/share/ozai-webui/templates";
|
|
|
|
};
|
|
|
|
|
2024-05-29 18:43:06 +02:00
|
|
|
serviceConfig = {
|
2024-05-31 18:06:33 +02:00
|
|
|
#ExecStart = "${self.packages.x86_64-linux.ozai-webui-run}/bin/run ${config.services.ozai-webui.host} ${toString(config.services.ozai-webui.port)} ${self.packages.x86_64-linux.default}/bin";
|
|
|
|
ExecStart = "${self.packages.x86_64-linux.ozai-webui-run}/bin/run ${config.services.ozai-webui.host} ${toString(config.services.ozai-webui.port)} ${self.packages.x86_64-linux.default}/lib/python3.11/site-packages/";
|
|
|
|
#ExecStart = "${self.packages.x86_64-linux.default}/bin/ozai_webui";
|
2024-05-29 18:43:06 +02:00
|
|
|
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
|
|
|
};
|
|
|
|
}
|
|
|
|
|