From 0a0dbe468f37618f918ff399f146581b9e4d2683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gutyina=20Gerg=C5=91?= Date: Sat, 7 Mar 2026 18:24:49 +0100 Subject: [PATCH 1/8] librechat: replace npm deps patch with fetcher version 2 --- .../li/librechat/0004-fix-deps-v080.patch | 68 ------------------- pkgs/by-name/li/librechat/package.nix | 15 +--- 2 files changed, 2 insertions(+), 81 deletions(-) delete mode 100644 pkgs/by-name/li/librechat/0004-fix-deps-v080.patch diff --git a/pkgs/by-name/li/librechat/0004-fix-deps-v080.patch b/pkgs/by-name/li/librechat/0004-fix-deps-v080.patch deleted file mode 100644 index 4f76cd8cb7f8..000000000000 --- a/pkgs/by-name/li/librechat/0004-fix-deps-v080.patch +++ /dev/null @@ -1,68 +0,0 @@ -diff --git a/client/package.json b/client/package.json -index f96aefa2d..ef3050f72 100644 ---- a/client/package.json -+++ b/client/package.json -@@ -121,7 +121,7 @@ - "@tanstack/react-query-devtools": "^4.29.0", - "@testing-library/dom": "^9.3.0", - "@testing-library/jest-dom": "^5.16.5", -- "@testing-library/react": "^14.0.0", -+ "@testing-library/react": "^14.3.1", - "@testing-library/user-event": "^14.4.3", - "@types/jest": "^29.5.14", - "@types/js-cookie": "^3.0.6", -diff --git a/package-lock.json b/package-lock.json -index 5b484fd55..7cbc13f49 100644 ---- a/package-lock.json -+++ b/package-lock.json -@@ -20,6 +20,7 @@ - "@eslint/js": "^9.20.0", - "@microsoft/eslint-formatter-sarif": "^3.1.0", - "@playwright/test": "^1.50.1", -+ "@testing-library/react": "^14.3.1", - "@types/react-virtualized": "^9.22.0", - "caniuse-lite": "^1.0.30001741", - "cross-env": "^7.0.3", -@@ -2718,7 +2719,7 @@ - "@tanstack/react-query-devtools": "^4.29.0", - "@testing-library/dom": "^9.3.0", - "@testing-library/jest-dom": "^5.16.5", -- "@testing-library/react": "^14.0.0", -+ "@testing-library/react": "^14.3.1", - "@testing-library/user-event": "^14.4.3", - "@types/jest": "^29.5.14", - "@types/js-cookie": "^3.0.6", -@@ -51744,7 +51745,7 @@ - "@rollup/plugin-replace": "^5.0.5", - "@rollup/plugin-terser": "^0.4.4", - "@tanstack/react-query": "^4.28.0", -- "@testing-library/react": "^14.0.0", -+ "@testing-library/react": "^16.3.0", - "@types/react": "^18.2.11", - "@types/react-dom": "^18.2.4", - "caniuse-lite": "^1.0.30001741", -diff --git a/package.json b/package.json -index 693de111d..5e58ab1f0 100644 ---- a/package.json -+++ b/package.json -@@ -99,6 +99,7 @@ - "@eslint/js": "^9.20.0", - "@microsoft/eslint-formatter-sarif": "^3.1.0", - "@playwright/test": "^1.50.1", -+ "@testing-library/react": "^14.3.1", - "@types/react-virtualized": "^9.22.0", - "caniuse-lite": "^1.0.30001741", - "cross-env": "^7.0.3", -diff --git a/packages/client/package.json b/packages/client/package.json -index 71aac0c29..ab6fabca1 100644 ---- a/packages/client/package.json -+++ b/packages/client/package.json -@@ -75,7 +75,7 @@ - "@rollup/plugin-replace": "^5.0.5", - "@rollup/plugin-terser": "^0.4.4", - "@tanstack/react-query": "^4.28.0", -- "@testing-library/react": "^14.0.0", -+ "@testing-library/react": "^16.3.0", - "@types/react": "^18.2.11", - "@types/react-dom": "^18.2.4", - "caniuse-lite": "^1.0.30001741", diff --git a/pkgs/by-name/li/librechat/package.nix b/pkgs/by-name/li/librechat/package.nix index f29974398304..c12d63739ca8 100644 --- a/pkgs/by-name/li/librechat/package.nix +++ b/pkgs/by-name/li/librechat/package.nix @@ -1,7 +1,6 @@ { lib, buildNpmPackage, - fetchNpmDeps, fetchFromGitHub, nodejs_22, pkg-config, @@ -38,20 +37,10 @@ buildNpmPackage rec { # directory as well. Again, we patch this to be relative to the current working # directory instead. ./0003-upload-paths.patch - # The npm dependencies are causing issues with the build. The package @testing-library/react - # appears to not be included in NPM deps, even though it is present in the project - # This patch fixes this by placing the dependency in different files and regenerating the - # lock file. - ./0004-fix-deps-v080.patch ]; - npmDepsHash = "sha256-97cEw6VD7FoVayrxClHuS1iUcQmDw7/aUoUV6ektvOY="; - npmDeps = fetchNpmDeps { - inherit src; - name = "${pname}-${version}-npm-deps-patched"; - hash = npmDepsHash; - patches = [ ./0004-fix-deps-v080.patch ]; - }; + npmDepsFetcherVersion = 2; + npmDepsHash = "sha256-JXXOJDkh+do8ZOf4KHyiH7igMeC8WkwflMNx1rZRY3g="; # npm dependency install fails with nodejs_24: https://github.com/NixOS/nixpkgs/issues/474535 nodejs = nodejs_22; From da5b151f79b40385006060781f266a6b7e19a912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gutyina=20Gerg=C5=91?= Date: Sat, 7 Mar 2026 18:41:57 +0100 Subject: [PATCH 2/8] librechat: remove unneded makeCacheWritable --- pkgs/by-name/li/librechat/package.nix | 3 --- 1 file changed, 3 deletions(-) diff --git a/pkgs/by-name/li/librechat/package.nix b/pkgs/by-name/li/librechat/package.nix index c12d63739ca8..ff9088cdf25b 100644 --- a/pkgs/by-name/li/librechat/package.nix +++ b/pkgs/by-name/li/librechat/package.nix @@ -54,9 +54,6 @@ buildNpmPackage rec { vips ]; - # required for sharp - makeCacheWritable = true; - npmBuildScript = "frontend"; npmPruneFlags = [ "--production" ]; From 95b9dc0e54811be395467ce54a7c75114b9d6207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gutyina=20Gerg=C5=91?= Date: Sat, 7 Mar 2026 20:09:41 +0100 Subject: [PATCH 3/8] librechat: migrate to finalAttrs --- pkgs/by-name/li/librechat/package.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/li/librechat/package.nix b/pkgs/by-name/li/librechat/package.nix index ff9088cdf25b..2aace8ec85e9 100644 --- a/pkgs/by-name/li/librechat/package.nix +++ b/pkgs/by-name/li/librechat/package.nix @@ -10,14 +10,14 @@ nixosTests, }: -buildNpmPackage rec { +buildNpmPackage (finalAttrs: { pname = "librechat"; version = "0.8.0"; src = fetchFromGitHub { owner = "danny-avila"; repo = "LibreChat"; - tag = "v${version}"; + tag = "v${finalAttrs.version}"; hash = "sha256-DTmb9J2nsMy6f+V6BgRtFgpTwOi9OQnvikSx4QZQ0HI="; }; @@ -87,4 +87,4 @@ buildNpmPackage rec { maintainers = with lib.maintainers; [ niklaskorz ]; mainProgram = "librechat-server"; }; -} +}) From 0d96729ee4b876a2c28e5338e577d4ab18fb91d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gutyina=20Gerg=C5=91?= Date: Sat, 7 Mar 2026 20:10:01 +0100 Subject: [PATCH 4/8] librechat: 0.8.0 -> 0.8.4 Fixes CVE-2026-31949 Changelogs: - https://github.com/danny-avila/LibreChat/releases/tag/v0.8.4 - https://github.com/danny-avila/LibreChat/releases/tag/v0.8.3 - https://github.com/danny-avila/LibreChat/releases/tag/v0.8.2 - https://github.com/danny-avila/LibreChat/releases/tag/v0.8.1 --- pkgs/by-name/li/librechat/0001-npm-pack.patch | 6 ++-- pkgs/by-name/li/librechat/0002-logs.patch | 32 +++++++++---------- pkgs/by-name/li/librechat/package.nix | 11 +++++-- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/pkgs/by-name/li/librechat/0001-npm-pack.patch b/pkgs/by-name/li/librechat/0001-npm-pack.patch index 880c67d03c2e..3bb147622d70 100644 --- a/pkgs/by-name/li/librechat/0001-npm-pack.patch +++ b/pkgs/by-name/li/librechat/0001-npm-pack.patch @@ -2,7 +2,7 @@ diff --git a/package.json b/package.json index 2131951..91e4846 100644 --- a/package.json +++ b/package.json -@@ -114,5 +114,15 @@ +@@ -114,5 +114,13 @@ "admin/", "packages/" ] @@ -10,9 +10,7 @@ index 2131951..91e4846 100644 + "files": [ + "api", + "client/dist", -+ "packages/data-provider", -+ "packages/data-schemas", -+ "packages/mcp" ++ "packages" + ], + "bin": { + "librechat-server": "api/server/index.js" diff --git a/pkgs/by-name/li/librechat/0002-logs.patch b/pkgs/by-name/li/librechat/0002-logs.patch index 64cc268277c3..dab413703655 100644 --- a/pkgs/by-name/li/librechat/0002-logs.patch +++ b/pkgs/by-name/li/librechat/0002-logs.patch @@ -1,26 +1,26 @@ diff --git a/api/config/meiliLogger.js b/api/config/meiliLogger.js -index 195b387..d445e54 100644 +index 398672da5..fcd6864f8 100644 --- a/api/config/meiliLogger.js +++ b/api/config/meiliLogger.js -@@ -2,7 +2,7 @@ const path = require('path'); - const winston = require('winston'); - require('winston-daily-rotate-file'); +@@ -26,7 +26,7 @@ const getLogDir = () => { + } --const logDir = path.join(__dirname, '..', 'logs'); -+const logDir = path.join('.', 'logs'); - - const { NODE_ENV } = process.env; + // Local development: use api/logs relative to this file +- return path.join(__dirname, '..', 'logs'); ++ return path.join('.', 'logs'); + }; + const logDir = getLogDir(); diff --git a/api/config/winston.js b/api/config/winston.js -index 8f51b99..2ebd041 100644 +index 93b84f7c4..4276bd6c2 100644 --- a/api/config/winston.js +++ b/api/config/winston.js -@@ -3,7 +3,7 @@ const winston = require('winston'); - require('winston-daily-rotate-file'); - const { redactFormat, redactMessage, debugTraverse, jsonTruncateFormat } = require('./parsers'); +@@ -27,7 +27,7 @@ const getLogDir = () => { + } --const logDir = path.join(__dirname, '..', 'logs'); -+const logDir = path.join('.', 'logs'); + // Local development: use api/logs relative to this file +- return path.join(__dirname, '..', 'logs'); ++ return path.join('.', 'logs'); + }; - const { NODE_ENV, DEBUG_LOGGING = true, DEBUG_CONSOLE = false, CONSOLE_JSON = false } = process.env; - \ No newline at end of file + const logDir = getLogDir(); \ No newline at end of file diff --git a/pkgs/by-name/li/librechat/package.nix b/pkgs/by-name/li/librechat/package.nix index 2aace8ec85e9..021a6a216d81 100644 --- a/pkgs/by-name/li/librechat/package.nix +++ b/pkgs/by-name/li/librechat/package.nix @@ -12,13 +12,13 @@ buildNpmPackage (finalAttrs: { pname = "librechat"; - version = "0.8.0"; + version = "0.8.4"; src = fetchFromGitHub { owner = "danny-avila"; repo = "LibreChat"; tag = "v${finalAttrs.version}"; - hash = "sha256-DTmb9J2nsMy6f+V6BgRtFgpTwOi9OQnvikSx4QZQ0HI="; + hash = "sha256-XiPnTKiSOMezUZuhkaGJ0xHiT7jrz8OYbZrvq5gb/V8="; }; patches = [ @@ -40,7 +40,7 @@ buildNpmPackage (finalAttrs: { ]; npmDepsFetcherVersion = 2; - npmDepsHash = "sha256-JXXOJDkh+do8ZOf4KHyiH7igMeC8WkwflMNx1rZRY3g="; + npmDepsHash = "sha256-h15rNYl2QYnh7/cJvA7lrRqmXw8Ri2QKTfTr7w7+mMo="; # npm dependency install fails with nodejs_24: https://github.com/NixOS/nixpkgs/issues/474535 nodejs = nodejs_22; @@ -57,6 +57,11 @@ buildNpmPackage (finalAttrs: { npmBuildScript = "frontend"; npmPruneFlags = [ "--production" ]; + # npmConfigHook only patches the root node_modules + postConfigure = '' + patchShebangs client/node_modules + ''; + # For reasons beyond my understanding, the api and client directory disappears after the build finishes. # Hence, the build fails with broken symlinks and if the symlink is removed, # starting LibreChat fails with a "module not found" error. From 03ae70618aaeb9bb0ac34a8db65374f9db6c4a3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gutyina=20Gerg=C5=91?= Date: Sat, 7 Mar 2026 20:32:35 +0100 Subject: [PATCH 5/8] nixos/librechat: add log directory option instead of hardcoding it in the package --- nixos/modules/services/web-apps/librechat.nix | 9 +++++++ pkgs/by-name/li/librechat/0002-logs.patch | 26 ------------------- ...ad-paths.patch => 0002-upload-paths.patch} | 0 pkgs/by-name/li/librechat/package.nix | 18 +++++++------ 4 files changed, 19 insertions(+), 34 deletions(-) delete mode 100644 pkgs/by-name/li/librechat/0002-logs.patch rename pkgs/by-name/li/librechat/{0003-upload-paths.patch => 0002-upload-paths.patch} (100%) diff --git a/nixos/modules/services/web-apps/librechat.nix b/nixos/modules/services/web-apps/librechat.nix index 120d6d092268..7313779305d8 100644 --- a/nixos/modules/services/web-apps/librechat.nix +++ b/nixos/modules/services/web-apps/librechat.nix @@ -85,6 +85,15 @@ in example = 2309; description = "The value that will be passed to the PORT environment variable, telling LibreChat what to listen on."; }; + LIBRECHAT_LOG_DIR = lib.mkOption { + type = lib.types.str; + default = "${cfg.dataDir}/logs"; + defaultText = lib.literalExpression "/var/lib/librechat/logs"; + description = '' + Logs will be saved into this directory. + By default it is relative to `services.librechat.dataDir`. + ''; + }; }; }; example = { diff --git a/pkgs/by-name/li/librechat/0002-logs.patch b/pkgs/by-name/li/librechat/0002-logs.patch deleted file mode 100644 index dab413703655..000000000000 --- a/pkgs/by-name/li/librechat/0002-logs.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/api/config/meiliLogger.js b/api/config/meiliLogger.js -index 398672da5..fcd6864f8 100644 ---- a/api/config/meiliLogger.js -+++ b/api/config/meiliLogger.js -@@ -26,7 +26,7 @@ const getLogDir = () => { - } - - // Local development: use api/logs relative to this file -- return path.join(__dirname, '..', 'logs'); -+ return path.join('.', 'logs'); - }; - - const logDir = getLogDir(); -diff --git a/api/config/winston.js b/api/config/winston.js -index 93b84f7c4..4276bd6c2 100644 ---- a/api/config/winston.js -+++ b/api/config/winston.js -@@ -27,7 +27,7 @@ const getLogDir = () => { - } - - // Local development: use api/logs relative to this file -- return path.join(__dirname, '..', 'logs'); -+ return path.join('.', 'logs'); - }; - - const logDir = getLogDir(); \ No newline at end of file diff --git a/pkgs/by-name/li/librechat/0003-upload-paths.patch b/pkgs/by-name/li/librechat/0002-upload-paths.patch similarity index 100% rename from pkgs/by-name/li/librechat/0003-upload-paths.patch rename to pkgs/by-name/li/librechat/0002-upload-paths.patch diff --git a/pkgs/by-name/li/librechat/package.nix b/pkgs/by-name/li/librechat/package.nix index 021a6a216d81..6a09ac2d8aa5 100644 --- a/pkgs/by-name/li/librechat/package.nix +++ b/pkgs/by-name/li/librechat/package.nix @@ -29,14 +29,9 @@ buildNpmPackage (finalAttrs: { # Also, we set the `bin` property to the server script to benefit from the # auto-generated wrapper. ./0001-npm-pack.patch - # LibreChat tries writing logs to the package directory, which is immutable - # in our case. We patch the log directory to target the current working directory - # instead, which in case of NixOS will be the service's data directory. - ./0002-logs.patch - # Similarly to the logs, user uploads are by default written to the package - # directory as well. Again, we patch this to be relative to the current working - # directory instead. - ./0003-upload-paths.patch + # User uploads are by default written to the package directory as well. + # We patch this to be relative to the current working directory instead. + ./0002-upload-paths.patch ]; npmDepsFetcherVersion = 2; @@ -57,6 +52,13 @@ buildNpmPackage (finalAttrs: { npmBuildScript = "frontend"; npmPruneFlags = [ "--production" ]; + makeWrapperArgs = [ + # Upstream defaults to the immutable package directory. + # As a functioning default, we set this to the current working directory (through a relative logs path), + # but make it easy for the module to override. + "--set-default LIBRECHAT_LOG_DIR ./logs" + ]; + # npmConfigHook only patches the root node_modules postConfigure = '' patchShebangs client/node_modules From d0200948ee45b59d5bcb4fbd77c3996f58ea31cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gutyina=20Gerg=C5=91?= Date: Sat, 7 Mar 2026 20:51:15 +0100 Subject: [PATCH 6/8] nixos/librechat: set config version by default Looks like after upgrading from 0.8.0 to 0.8.2 this is mandatory. --- nixos/modules/services/web-apps/librechat.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/web-apps/librechat.nix b/nixos/modules/services/web-apps/librechat.nix index 7313779305d8..932f81404af3 100644 --- a/nixos/modules/services/web-apps/librechat.nix +++ b/nixos/modules/services/web-apps/librechat.nix @@ -129,9 +129,11 @@ in type = lib.types.submodule { freeformType = format.type; }; - default = { }; + default = { + version = "1.2.1"; + }; example = { - version = "1.0.8"; + version = "1.2.1"; cache = true; interface = { privacyPolicy = { From 33492d7d3b880f0fe645902149b9d10977014299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gutyina=20Gerg=C5=91?= Date: Sat, 7 Mar 2026 21:11:34 +0100 Subject: [PATCH 7/8] librechat: add changelog --- pkgs/by-name/li/librechat/package.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/by-name/li/librechat/package.nix b/pkgs/by-name/li/librechat/package.nix index 6a09ac2d8aa5..ca147ba877a4 100644 --- a/pkgs/by-name/li/librechat/package.nix +++ b/pkgs/by-name/li/librechat/package.nix @@ -90,6 +90,7 @@ buildNpmPackage (finalAttrs: { meta = { description = "Open-source app for all your AI conversations, fully customizable and compatible with any AI provider"; homepage = "https://github.com/danny-avila/LibreChat"; + changelog = "https://www.librechat.ai/changelog/${finalAttrs.src.tag}"; license = lib.licenses.mit; maintainers = with lib.maintainers; [ niklaskorz ]; mainProgram = "librechat-server"; From 58002df66d70afab3b0cf98bbe1a3b2c09902543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gutyina=20Gerg=C5=91?= Date: Sat, 7 Mar 2026 21:12:03 +0100 Subject: [PATCH 8/8] librechat: add maintainer gepbird --- pkgs/by-name/li/librechat/package.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/li/librechat/package.nix b/pkgs/by-name/li/librechat/package.nix index ca147ba877a4..68129fb5e535 100644 --- a/pkgs/by-name/li/librechat/package.nix +++ b/pkgs/by-name/li/librechat/package.nix @@ -92,7 +92,10 @@ buildNpmPackage (finalAttrs: { homepage = "https://github.com/danny-avila/LibreChat"; changelog = "https://www.librechat.ai/changelog/${finalAttrs.src.tag}"; license = lib.licenses.mit; - maintainers = with lib.maintainers; [ niklaskorz ]; + maintainers = with lib.maintainers; [ + gepbird + niklaskorz + ]; mainProgram = "librechat-server"; }; })