2023-08-13 17:00:41 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
inputs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}: let
|
2023-02-26 18:32:29 +00:00
|
|
|
fqdn = "bolty.raptor-carp.ts.net";
|
|
|
|
port = 30001;
|
|
|
|
path = "/data/grafana";
|
|
|
|
certPath = "${path}/cert.pem";
|
|
|
|
keyPath = "${path}/key.pem";
|
|
|
|
in {
|
2023-08-13 17:00:41 +01:00
|
|
|
networking.firewall.allowedTCPPorts = [port];
|
2023-02-26 18:32:29 +00:00
|
|
|
|
|
|
|
systemd.services.grafana-prep = {
|
|
|
|
script = ''
|
|
|
|
mkdir -p ${path}
|
|
|
|
cp -rv /var/lib/tailscale-certs/cert.pem ${certPath}
|
|
|
|
cp -rv /var/lib/tailscale-certs/key.pem ${keyPath}
|
|
|
|
chown -Rv grafana:grafana ${path}
|
|
|
|
'';
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
ReloadPropagatedFrom = "tailscale-cert.service";
|
|
|
|
};
|
2023-08-13 17:00:41 +01:00
|
|
|
before = ["grafana.service"];
|
|
|
|
wantedBy = ["multi-user.target"];
|
2023-02-26 18:32:29 +00:00
|
|
|
after = [
|
|
|
|
"network.target"
|
|
|
|
"network-online.target"
|
|
|
|
"tailscaled.service"
|
|
|
|
"tailscale-cert.service"
|
|
|
|
];
|
2023-08-13 17:00:41 +01:00
|
|
|
wants = ["tailscale-cert.service"];
|
2023-02-26 18:32:29 +00:00
|
|
|
};
|
|
|
|
|
2023-04-22 09:44:50 +01:00
|
|
|
systemd.services.grafana = {
|
|
|
|
after = [
|
|
|
|
"network.target"
|
|
|
|
"network-online.target"
|
|
|
|
"tailscaled.service"
|
|
|
|
"tailscale-cert.service"
|
|
|
|
"tailscale-auth.service"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2023-02-26 18:32:29 +00:00
|
|
|
services.grafana = {
|
|
|
|
enable = true;
|
|
|
|
dataDir = path;
|
|
|
|
settings.server = {
|
|
|
|
protocol = "https";
|
|
|
|
domain = fqdn;
|
|
|
|
http_port = port;
|
|
|
|
http_addr = fqdn;
|
|
|
|
cert_file = certPath;
|
|
|
|
cert_key = keyPath;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|