feat(librechat): add ability to define config settings in nix way
This commit is contained in:
parent
9f6f870d6c
commit
b2f596e5b1
2 changed files with 105 additions and 81 deletions
|
@ -13,6 +13,18 @@ in
|
|||
enable = lib.mkEnableOption "Whether to enable the LibreChat server.";
|
||||
openFirewall = lib.mkEnableOption "Whether to open the port in the firewall.";
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = lib.types.attrs;
|
||||
default = { };
|
||||
example = # nix
|
||||
''
|
||||
{
|
||||
|
||||
}
|
||||
'';
|
||||
description = "A free-form attribute set that will be written to librechat.yaml.";
|
||||
};
|
||||
|
||||
path = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "/var/lib/librechat";
|
||||
|
@ -187,7 +199,14 @@ in
|
|||
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
config = lib.mkIf cfg.enable (
|
||||
let
|
||||
configFile = pkgs.writeTextFile {
|
||||
name = "librechat.yaml";
|
||||
text = lib.generators.toYAML { } cfg.settings;
|
||||
};
|
||||
in
|
||||
{
|
||||
|
||||
assertions = [
|
||||
{
|
||||
|
@ -253,6 +272,7 @@ in
|
|||
export JWT_SECRET=$(${pkgs.systemd}/bin/systemd-creds cat JWT_SECRET_FILE)
|
||||
export JWT_REFRESH_SECRET=$(${pkgs.systemd}/bin/systemd-creds cat JWT_REFRESH_SECRET_FILE)
|
||||
|
||||
export CONFIG_PATH=${configFile}
|
||||
export HOST=${cfg.host}
|
||||
export PORT=${builtins.toString cfg.port}
|
||||
export MONGO_URI="${cfg.mongodbURI}"
|
||||
|
@ -271,5 +291,6 @@ in
|
|||
description = "LibreChat server user";
|
||||
};
|
||||
users.groups.librechat = lib.mkIf (cfg.user == "librechat") { };
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
openFirewall = true;
|
||||
host = "0.0.0.0";
|
||||
mongodbURI = "mongodb://apollo:27017";
|
||||
settings = {
|
||||
version = "1.0.8";
|
||||
};
|
||||
auth = {
|
||||
allowEmailLogin = true;
|
||||
allowEmailRegistration = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue