feat(server): move librechat webapp config to its own module

This commit is contained in:
Mohammad Rafiq 2025-06-13 04:20:43 +08:00
parent 181e5d6ec8
commit ecad3fc68e
No known key found for this signature in database
2 changed files with 28 additions and 18 deletions

View file

@ -1,34 +1,48 @@
{ {
inputs,
config, config,
lib, lib,
inputs,
... ...
}: }:
let let
cfg = config.server.web-apps; inherit (lib) singleton mkEnableOption mkIf;
inherit (lib.pantheon) mkRootDomain mkPortOption mkStrOption;
cfg = config.server.web-apps.librechat;
upstreamCfg = config.services.librechat;
in in
{ {
imports = singleton "${inputs.rrvsh-nixpkgs}/nixos/modules/services/web-apps/librechat.nix";
imports = [ options.server.web-apps.librechat = {
"${inputs.rrvsh-nixpkgs}/nixos/modules/services/web-apps/librechat.nix" enable = mkEnableOption "";
]; port = mkPortOption 3080;
url = mkStrOption;
options.server.web-apps = { mongodbURI = mkStrOption // {
librechat.enable = lib.mkEnableOption ""; default = "mongodb://${config.system.hostname}:27017/LibreChat";
};
}; };
config = lib.mkIf cfg.librechat.enable { config = mkIf cfg.enable {
environment.persistence."/persist".directories = singleton {
directory = upstreamCfg.logDir;
inherit (upstreamCfg) user group;
};
server.networking.ddns.domains = singleton (mkRootDomain cfg.url);
server.web-servers.nginx.proxies = lib.mkIf config.server.web-servers.nginx.enable (singleton {
source = cfg.url;
target = "http://${config.system.hostname}:${builtins.toString cfg.port}";
});
services.librechat = { services.librechat = {
enable = true; enable = true;
openFirewall = true; openFirewall = true;
port = 3080; inherit (cfg) port;
env = { env = {
HOST = "0.0.0.0"; HOST = "0.0.0.0";
ALLOW_REGISTRATION = "true"; ALLOW_REGISTRATION = "true";
NO_INDEX = "true"; NO_INDEX = "true";
MONGO_URI = "mongodb://apollo:27017/LibreChat"; MONGO_URI = cfg.mongodbURI;
DOMAIN_CLIENT = "https://chat.bwfiq.com"; DOMAIN_CLIENT = cfg.url;
DOMAIN_SERVER = "https://chat.bwfiq.com"; DOMAIN_SERVER = cfg.url;
ENDPOINTS = "anthropic,agents,google"; ENDPOINTS = "anthropic,agents,google";
}; };
credentials = { credentials = {

View file

@ -35,6 +35,7 @@
}; };
web-apps = { web-apps = {
librechat.enable = true; librechat.enable = true;
librechat.url = "chat.bwfiq.com";
mattermost.enable = true; mattermost.enable = true;
mattermost.url = "mm.bwfiq.com"; mattermost.url = "mm.bwfiq.com";
}; };
@ -47,11 +48,6 @@
source = "aenyrathia.wiki"; source = "aenyrathia.wiki";
target = "http://helios:5896"; target = "http://helios:5896";
} }
{
#TODO: merge into librechat module
source = "chat.bwfiq.com";
target = "http://localhost:3080";
}
{ {
source = "il.bwfiq.com"; source = "il.bwfiq.com";
target = "http://helios:2283"; target = "http://helios:2283";