mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 14:01:34 +01:00
49 lines
1.1 KiB
Nix
49 lines
1.1 KiB
Nix
{ config, lib, ... }:
|
|
let
|
|
cfg = config.custom.web-services.victorialogs;
|
|
in
|
|
{
|
|
options.custom.web-services.victorialogs = {
|
|
enable = lib.mkEnableOption "";
|
|
domain = lib.mkOption {
|
|
type = lib.types.nonEmptyStr;
|
|
default = "";
|
|
};
|
|
port = lib.mkOption {
|
|
type = lib.types.port;
|
|
default = 9428;
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
meta = {
|
|
domains.local = [ cfg.domain ];
|
|
ports.tcp = [ cfg.port ];
|
|
};
|
|
|
|
users = {
|
|
users.victorialogs = {
|
|
isSystemUser = true;
|
|
group = config.users.groups.victoriametrics.name;
|
|
};
|
|
groups.victorialogs = { };
|
|
};
|
|
|
|
systemd.services.victorialogs.serviceConfig = {
|
|
DynamicUser = lib.mkForce false;
|
|
User = config.users.users.victorialogs.name;
|
|
Group = config.users.groups.victorialogs.name;
|
|
};
|
|
|
|
services.victorialogs = {
|
|
enable = true;
|
|
listenAddress = "localhost:${toString cfg.port}";
|
|
};
|
|
|
|
custom = {
|
|
services.caddy.virtualHosts.${cfg.domain}.port = cfg.port;
|
|
|
|
persistence.directories = [ "/var/lib/${config.services.victorialogs.stateDir}" ];
|
|
};
|
|
};
|
|
}
|