nixos/librechat: add log directory option instead of hardcoding it in the package

This commit is contained in:
Gutyina Gergő
2026-03-23 10:13:06 +01:00
committed by Niklas Korz
parent 0d96729ee4
commit 03ae70618a
4 changed files with 19 additions and 34 deletions
@@ -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 = {
-26
View File
@@ -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();
+10 -8
View File
@@ -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