From 22f6fb046d369beba316834d265786fa4baedff4 Mon Sep 17 00:00:00 2001 From: Simao Gomes Viana Date: Thu, 30 Oct 2025 11:18:12 +0100 Subject: [PATCH 1/2] librechat: 0.7.8 -> 0.7.9 --- .../by-name/li/librechat/0004-logs-v079.patch | 26 +++++++++++++++++++ pkgs/by-name/li/librechat/package.nix | 20 +++++++++++--- 2 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 pkgs/by-name/li/librechat/0004-logs-v079.patch diff --git a/pkgs/by-name/li/librechat/0004-logs-v079.patch b/pkgs/by-name/li/librechat/0004-logs-v079.patch new file mode 100644 index 000000000000..db30388675a5 --- /dev/null +++ b/pkgs/by-name/li/librechat/0004-logs-v079.patch @@ -0,0 +1,26 @@ +diff --git a/packages/data-schemas/src/config/meiliLogger.ts b/packages/data-schemas/src/config/meiliLogger.ts +index 0d4d39475..c38560d35 100644 +--- a/packages/data-schemas/src/config/meiliLogger.ts ++++ b/packages/data-schemas/src/config/meiliLogger.ts +@@ -2,7 +2,7 @@ import path from 'path'; + import winston from 'winston'; + import 'winston-daily-rotate-file'; + +-const logDir = path.join(__dirname, '..', '..', '..', 'api', 'logs'); ++const logDir = path.join('.', 'logs'); + + const { NODE_ENV, DEBUG_LOGGING = 'false' } = process.env; + +diff --git a/packages/data-schemas/src/config/winston.ts b/packages/data-schemas/src/config/winston.ts +index 7e5287296..dd68614bc 100644 +--- a/packages/data-schemas/src/config/winston.ts ++++ b/packages/data-schemas/src/config/winston.ts +@@ -3,7 +3,7 @@ import winston from 'winston'; + import 'winston-daily-rotate-file'; + import { redactFormat, redactMessage, debugTraverse, jsonTruncateFormat } from './parsers'; + +-const logDir = path.join(__dirname, '..', '..', '..', 'api', 'logs'); ++const logDir = path.join('.', 'logs'); + + const { NODE_ENV, DEBUG_LOGGING, CONSOLE_JSON, DEBUG_CONSOLE } = process.env; + diff --git a/pkgs/by-name/li/librechat/package.nix b/pkgs/by-name/li/librechat/package.nix index ba5b361880a9..792cb7fde3b5 100644 --- a/pkgs/by-name/li/librechat/package.nix +++ b/pkgs/by-name/li/librechat/package.nix @@ -10,13 +10,13 @@ buildNpmPackage rec { pname = "librechat"; - version = "0.7.8"; + version = "0.7.9"; src = fetchFromGitHub { owner = "danny-avila"; repo = "LibreChat"; tag = "v${version}"; - hash = "sha256-bo26EzpRjE2hbbx6oUo0tDsLMdVpWcazCIzA5sm5L34="; + hash = "sha256-0HEb8tFpiTjfN+RpwizK5POWsz5cRicSdZwYPmUaLDA="; }; patches = [ @@ -35,9 +35,13 @@ buildNpmPackage rec { # directory as well. Again, we patch this to be relative to the current working # directory instead. ./0003-upload-paths.patch + # Since 0.7.9, there are two more files that try to write logs to the package + # directory. We patch the log directory to target the current working directory + # instead for these two as well. + ./0004-logs-v079.patch ]; - npmDepsHash = "sha256-knmS2I6AiSdV2bSnNBThbVHdkpk6iXiRuk4adciDK1M="; + npmDepsHash = "sha256-tOxanPXry52lD39xlT6rqKVF+Pk6m3FpTv/8wctKAWY="; nativeBuildInputs = [ pkg-config @@ -52,7 +56,15 @@ buildNpmPackage rec { makeCacheWritable = true; npmBuildScript = "frontend"; - npmPruneFlags = [ "--omit=dev" ]; + npmPruneFlags = [ "--production" ]; + + # For reasons beyond my understanding, the api directory disappears after the build finishes. + # Hence, starting LibreChat fails with a "module not found" error due to a broken symlink. + # This is a fixup that copies the missing files to the appropriate location. + preFixup = '' + mkdir -p $out/lib/node_modules/LibreChat/packages/api + cp -R packages/api/dist/. $out/lib/node_modules/LibreChat/packages/api + ''; passthru = { updateScript = nix-update-script { From e75998fe12f678bc73dc1dc9b729118aff8e5693 Mon Sep 17 00:00:00 2001 From: Simao Gomes Viana Date: Thu, 30 Oct 2025 15:53:16 +0100 Subject: [PATCH 2/2] librechat: 0.7.9 -> 0.8.0 --- .../li/librechat/0004-fix-deps-v080.patch | 68 +++++++++++++++++++ .../by-name/li/librechat/0004-logs-v079.patch | 26 ------- pkgs/by-name/li/librechat/package.nix | 29 +++++--- 3 files changed, 88 insertions(+), 35 deletions(-) create mode 100644 pkgs/by-name/li/librechat/0004-fix-deps-v080.patch delete mode 100644 pkgs/by-name/li/librechat/0004-logs-v079.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 new file mode 100644 index 000000000000..4f76cd8cb7f8 --- /dev/null +++ b/pkgs/by-name/li/librechat/0004-fix-deps-v080.patch @@ -0,0 +1,68 @@ +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/0004-logs-v079.patch b/pkgs/by-name/li/librechat/0004-logs-v079.patch deleted file mode 100644 index db30388675a5..000000000000 --- a/pkgs/by-name/li/librechat/0004-logs-v079.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/packages/data-schemas/src/config/meiliLogger.ts b/packages/data-schemas/src/config/meiliLogger.ts -index 0d4d39475..c38560d35 100644 ---- a/packages/data-schemas/src/config/meiliLogger.ts -+++ b/packages/data-schemas/src/config/meiliLogger.ts -@@ -2,7 +2,7 @@ import path from 'path'; - import winston from 'winston'; - import 'winston-daily-rotate-file'; - --const logDir = path.join(__dirname, '..', '..', '..', 'api', 'logs'); -+const logDir = path.join('.', 'logs'); - - const { NODE_ENV, DEBUG_LOGGING = 'false' } = process.env; - -diff --git a/packages/data-schemas/src/config/winston.ts b/packages/data-schemas/src/config/winston.ts -index 7e5287296..dd68614bc 100644 ---- a/packages/data-schemas/src/config/winston.ts -+++ b/packages/data-schemas/src/config/winston.ts -@@ -3,7 +3,7 @@ import winston from 'winston'; - import 'winston-daily-rotate-file'; - import { redactFormat, redactMessage, debugTraverse, jsonTruncateFormat } from './parsers'; - --const logDir = path.join(__dirname, '..', '..', '..', 'api', 'logs'); -+const logDir = path.join('.', 'logs'); - - const { NODE_ENV, DEBUG_LOGGING, CONSOLE_JSON, DEBUG_CONSOLE } = process.env; - diff --git a/pkgs/by-name/li/librechat/package.nix b/pkgs/by-name/li/librechat/package.nix index 792cb7fde3b5..1bdedae56441 100644 --- a/pkgs/by-name/li/librechat/package.nix +++ b/pkgs/by-name/li/librechat/package.nix @@ -1,6 +1,7 @@ { lib, buildNpmPackage, + fetchNpmDeps, fetchFromGitHub, pkg-config, node-gyp, @@ -10,13 +11,13 @@ buildNpmPackage rec { pname = "librechat"; - version = "0.7.9"; + version = "0.8.0"; src = fetchFromGitHub { owner = "danny-avila"; repo = "LibreChat"; tag = "v${version}"; - hash = "sha256-0HEb8tFpiTjfN+RpwizK5POWsz5cRicSdZwYPmUaLDA="; + hash = "sha256-DTmb9J2nsMy6f+V6BgRtFgpTwOi9OQnvikSx4QZQ0HI="; }; patches = [ @@ -35,13 +36,20 @@ buildNpmPackage rec { # directory as well. Again, we patch this to be relative to the current working # directory instead. ./0003-upload-paths.patch - # Since 0.7.9, there are two more files that try to write logs to the package - # directory. We patch the log directory to target the current working directory - # instead for these two as well. - ./0004-logs-v079.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-tOxanPXry52lD39xlT6rqKVF+Pk6m3FpTv/8wctKAWY="; + npmDepsHash = "sha256-97cEw6VD7FoVayrxClHuS1iUcQmDw7/aUoUV6ektvOY="; + npmDeps = fetchNpmDeps { + inherit src; + name = "${pname}-${version}-npm-deps-patched"; + hash = npmDepsHash; + patches = [ ./0004-fix-deps-v080.patch ]; + }; nativeBuildInputs = [ pkg-config @@ -58,12 +66,15 @@ buildNpmPackage rec { npmBuildScript = "frontend"; npmPruneFlags = [ "--production" ]; - # For reasons beyond my understanding, the api directory disappears after the build finishes. - # Hence, starting LibreChat fails with a "module not found" error due to a broken symlink. + # 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. # This is a fixup that copies the missing files to the appropriate location. preFixup = '' mkdir -p $out/lib/node_modules/LibreChat/packages/api cp -R packages/api/dist/. $out/lib/node_modules/LibreChat/packages/api + mkdir -p $out/lib/node_modules/LibreChat/packages/client + cp -R packages/client/dist/. $out/lib/node_modules/LibreChat/packages/client ''; passthru = {