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 {