···
···
"-storageDataPath=/var/lib/${cfg.stateDir}"
"-httpListenAddr=${cfg.listenAddress}"
+
++ lib.optionals (cfg.basicAuthUsername != null) [
+
"-httpAuth.username=${cfg.basicAuthUsername}"
+
++ lib.optionals (cfg.basicAuthPasswordFile != null) [
+
"-httpAuth.password=file://%d/basic_auth_password"
options.services.victorialogs = {
···
This directory will be created automatically using systemd's StateDirectory mechanism.
+
basicAuthUsername = lib.mkOption {
+
type = lib.types.nullOr lib.types.str;
+
Basic Auth username used to protect VictoriaLogs instance by authorization
+
basicAuthPasswordFile = lib.mkOption {
+
type = lib.types.nullOr lib.types.str;
+
File that contains the Basic Auth password used to protect VictoriaLogs instance by authorization
extraOptions = mkOption {
type = types.listOf types.str;
example = literalExpression ''
···
config = mkIf cfg.enable {
+
(cfg.basicAuthUsername == null && cfg.basicAuthPasswordFile == null)
+
|| (cfg.basicAuthUsername != null && cfg.basicAuthPasswordFile != null);
+
message = "Both basicAuthUsername and basicAuthPasswordFile must be set together to enable basicAuth functionality, or neither should be set.";
systemd.services.victorialogs = {
description = "VictoriaLogs logs database";
wantedBy = [ "multi-user.target" ];
···
+
ExecStart = lib.concatStringsSep " " [
+
(escapeShellArgs startCLIList)
+
(utils.escapeSystemdExecArgs cfg.extraOptions)
+
LoadCredential = lib.optional (
+
cfg.basicAuthPasswordFile != null
+
) "basic_auth_password:${cfg.basicAuthPasswordFile}";
RuntimeDirectory = "victorialogs";