nixos/applications/grafana.nix

61 lines
1 KiB
Nix
Raw Normal View History

{
lib,
config,
...
}:
2024-05-21 01:23:10 +00:00
with lib; let
name = "grafana";
2024-05-21 02:02:37 +00:00
cfg = config.services.skynet."${name}";
port = 4444;
2024-05-21 01:23:10 +00:00
in {
imports = [
./acme.nix
./dns.nix
];
options.services.skynet."${name}" = {
2024-05-21 01:23:10 +00:00
enable = mkEnableOption "Grafana Server";
host = {
ip = mkOption {
type = types.str;
};
name = mkOption {
type = types.str;
};
};
};
config = mkIf cfg.enable {
2024-05-21 01:23:10 +00:00
skynet_dns.records = [
{
record = "${name}";
r_type = "CNAME";
value = cfg.host.name;
}
];
skynet_acme.domains = [
"${name}.skynet.ie"
];
services.grafana = {
enable = true;
2024-05-21 02:02:37 +00:00
domain = "${name}.skynet.ie";
2024-05-21 02:40:58 +00:00
port = port;
addr = cfg.host.ip;
};
services.nginx.virtualHosts = {
"${name}.skynet.ie" = {
forceSSL = true;
useACMEHost = "skynet";
locations."/" = {
2024-05-21 02:40:58 +00:00
proxyPass = "http://localhost:${toString port}";
proxyWebsockets = true;
};
};
};
2024-05-21 01:23:10 +00:00
};
}