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/package.nix b/pkgs/by-name/li/librechat/package.nix index ba5b361880a9..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.8"; + version = "0.8.0"; src = fetchFromGitHub { owner = "danny-avila"; repo = "LibreChat"; tag = "v${version}"; - hash = "sha256-bo26EzpRjE2hbbx6oUo0tDsLMdVpWcazCIzA5sm5L34="; + hash = "sha256-DTmb9J2nsMy6f+V6BgRtFgpTwOi9OQnvikSx4QZQ0HI="; }; patches = [ @@ -35,9 +36,20 @@ 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-knmS2I6AiSdV2bSnNBThbVHdkpk6iXiRuk4adciDK1M="; + 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 @@ -52,7 +64,18 @@ buildNpmPackage rec { makeCacheWritable = true; npmBuildScript = "frontend"; - npmPruneFlags = [ "--omit=dev" ]; + npmPruneFlags = [ "--production" ]; + + # 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 = { updateScript = nix-update-script {