mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-17 11:10:03 +00:00
open-webui: Add environmentFile
option (#334830)
This commit is contained in:
commit
bcb04b0967
|
@ -60,6 +60,17 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
environmentFile = lib.mkOption {
|
||||
description = ''
|
||||
Environment file to be passed to the systemd service.
|
||||
Useful for passing secrets to the service to prevent them from being
|
||||
world-readable in the Nix store.
|
||||
'';
|
||||
type = lib.types.nullOr lib.types.path;
|
||||
default = null;
|
||||
example = "/var/lib/secrets/openWebuiSecrets";
|
||||
};
|
||||
|
||||
openFirewall = lib.mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
|
@ -86,6 +97,7 @@ in
|
|||
|
||||
serviceConfig = {
|
||||
ExecStart = "${lib.getExe cfg.package} serve --host ${cfg.host} --port ${toString cfg.port}";
|
||||
EnvironmentFile = lib.optional (cfg.environmentFile != null) cfg.environmentFile;
|
||||
WorkingDirectory = cfg.stateDir;
|
||||
StateDirectory = "open-webui";
|
||||
RuntimeDirectory = "open-webui";
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{ lib, ... }:
|
||||
{ config, lib, ... }:
|
||||
let
|
||||
mainPort = "8080";
|
||||
webuiName = "NixOS Test";
|
||||
in
|
||||
{
|
||||
name = "open-webui";
|
||||
|
@ -18,16 +19,31 @@ in
|
|||
# Requires network connection
|
||||
RAG_EMBEDDING_MODEL = "";
|
||||
};
|
||||
|
||||
# Test that environment variables can be
|
||||
# overridden through a file.
|
||||
environmentFile = config.node.pkgs.writeText "test.env" ''
|
||||
WEBUI_NAME="${webuiName}"
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
import json
|
||||
|
||||
machine.start()
|
||||
|
||||
machine.wait_for_unit("open-webui.service")
|
||||
machine.wait_for_open_port(${mainPort})
|
||||
|
||||
machine.succeed("curl http://127.0.0.1:${mainPort}")
|
||||
|
||||
# Load the Web UI config JSON and parse it.
|
||||
webui_config_json = machine.succeed("curl http://127.0.0.1:${mainPort}/api/config")
|
||||
webui_config = json.loads(webui_config_json)
|
||||
|
||||
# Check that the name was overridden via the environmentFile option.
|
||||
assert webui_config["name"] == "${webuiName} (Open WebUI)"
|
||||
'';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue