ozai-webui/flake.nix

72 lines
2.7 KiB
Nix
Raw Normal View History

2024-03-23 17:49:50 +01:00
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
2024-03-24 00:48:43 +01:00
outputs = { self, nixpkgs}:
2024-03-23 17:49:50 +01:00
let
2024-03-24 00:48:43 +01:00
supportedSystems = [ "x86_64-linux"];
2024-03-23 17:49:50 +01:00
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
in
{
packages = forAllSystems (system: let
2024-03-24 00:48:43 +01:00
python = pkgs.${system}.python3.withPackages (ps: [ps.flask ps.flask-socketio]);
ozaiWebui = import ./default.nix { inherit (pkgs.${system}) pkgs; };
2024-03-23 17:49:50 +01:00
in {
2024-03-24 00:48:43 +01:00
default = ozaiWebui;
2024-03-23 17:49:50 +01:00
});
devShells = forAllSystems (system: let
2024-03-24 00:48:43 +01:00
python = pkgs.${system}.python3.withPackages (ps: [ps.flask ps.flask-socketio]);
2024-03-23 17:49:50 +01:00
in {
default = pkgs.${system}.mkShellNoCC {
packages = with pkgs.${system}; [
2024-03-24 00:48:43 +01:00
python
2024-03-23 17:49:50 +01:00
];
};
});
2024-03-24 00:48:43 +01:00
nixosModules = forAllSystems (system: let
ozaiWebui = import ./default.nix { inherit (pkgs.${system}) pkgs; };
in {
ozai-webui = { config, pkgs, ... }: {
options.services.ozai-webui = {
enable = mkEnableOption "Ozai WebUI";
host = mkOption {
type = types.str;
default = "127.0.0.1";
description = "The host to run the server on";
};
port = mkOption {
type = types.int;
default = 8080;
description = "The port to run the server on";
};
ozaiUrl = mkOption {
type = types.str;
default = "http://localhost:8000/api/";
description = "The URL of the Ozai server";
};
secretKey = mkOption {
type = types.str;
default = "secret_key";
description = "The secret key for the Flask app";
};
};
config = mkIf config.services.ozai-webui.enable {
systemd.services.ozai-webui = {
description = "Ozai WebUI";
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}'";
Restart = "always";
};
};
};
};
});
};
}