{ description = "Ozai WebUI"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; }; 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 ''; }; 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"; }; }; 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 = "${pkgs.ozai-webui}/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"; }; }; }; }; }; }