68 lines
1.7 KiB
Nix
68 lines
1.7 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
let
|
|
vars = import ./vars.nix;
|
|
domain = vars.domain;
|
|
in
|
|
{
|
|
# vnStat for tracking network interface stats
|
|
services.vnstat.enable = true;
|
|
|
|
# https://wiki.nixos.org/wiki/Prometheus
|
|
services.prometheus = {
|
|
enable = true;
|
|
exporters = {
|
|
# TODO: DNS, Kea, Knot, other exporters
|
|
node = {
|
|
enable = true;
|
|
enabledCollectors = [ "systemd" ];
|
|
};
|
|
};
|
|
scrapeConfigs = [
|
|
{
|
|
job_name = "node";
|
|
static_configs = [{
|
|
targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ];
|
|
}];
|
|
}
|
|
];
|
|
};
|
|
|
|
# https://wiki.nixos.org/wiki/Grafana#Declarative_configuration
|
|
services.grafana = {
|
|
enable = true;
|
|
settings.server = {
|
|
http_port = 3001;
|
|
serve_from_sub_path = true;
|
|
root_url = "%(protocol)s://%(domain)s:%(http_port)s/grafana/";
|
|
};
|
|
provision = {
|
|
enable = true;
|
|
datasources.settings.datasources = [
|
|
{
|
|
name = "Prometheus";
|
|
type = "prometheus";
|
|
url = "http://localhost:${toString config.services.prometheus.port}";
|
|
}
|
|
];
|
|
};
|
|
};
|
|
|
|
services.caddy = {
|
|
enable = true;
|
|
virtualHosts."grouter.${domain}".extraConfig = ''
|
|
tls internal
|
|
@grafana path /grafana /grafana/*
|
|
handle @grafana {
|
|
reverse_proxy localhost:${toString config.services.grafana.settings.server.http_port}
|
|
}
|
|
redir /adghome /adghome/
|
|
handle_path /adghome/* {
|
|
reverse_proxy localhost:${toString config.services.adguardhome.port}
|
|
basic_auth {
|
|
Bob $2a$14$HsWmmzQTN68K3vwiRAfiUuqIjKoXEXaj9TOLUtG2mO1vFpdovmyBy
|
|
}
|
|
}
|
|
'';
|
|
};
|
|
}
|