···
···
"-storageDataPath=/var/lib/${cfg.stateDir}"
"-httpListenAddr=${cfg.listenAddress}"
27
-
++ cfg.extraOptions;
28
+
++ lib.optionals (cfg.basicAuthUsername != null) [
29
+
"-httpAuth.username=${cfg.basicAuthUsername}"
31
+
++ lib.optionals (cfg.basicAuthPasswordFile != null) [
32
+
"-httpAuth.password=file://%d/basic_auth_password"
options.services.victorialogs = {
···
This directory will be created automatically using systemd's StateDirectory mechanism.
54
+
basicAuthUsername = lib.mkOption {
56
+
type = lib.types.nullOr lib.types.str;
58
+
Basic Auth username used to protect VictoriaLogs instance by authorization
62
+
basicAuthPasswordFile = lib.mkOption {
64
+
type = lib.types.nullOr lib.types.str;
66
+
File that contains the Basic Auth password used to protect VictoriaLogs instance by authorization
extraOptions = mkOption {
type = types.listOf types.str;
example = literalExpression ''
53
-
"-httpAuth.username=username"
54
-
"-httpAuth.password=file:///abs/path/to/file"
···
config = mkIf cfg.enable {
88
+
(cfg.basicAuthUsername == null && cfg.basicAuthPasswordFile == null)
89
+
|| (cfg.basicAuthUsername != null && cfg.basicAuthPasswordFile != null);
90
+
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" ];
···
72
-
ExecStart = escapeShellArgs startCLIList;
101
+
ExecStart = lib.concatStringsSep " " [
102
+
(escapeShellArgs startCLIList)
103
+
(utils.escapeSystemdExecArgs cfg.extraOptions)
106
+
LoadCredential = lib.optional (
107
+
cfg.basicAuthPasswordFile != null
108
+
) "basic_auth_password:${cfg.basicAuthPasswordFile}";
RuntimeDirectory = "victorialogs";