nixos/applications/grafana.nix

71 lines
1.2 KiB
Nix
Raw Normal View History

{
lib,
config,
...
}:
2024-05-21 01:23:10 +00:00
with lib; let
name = "grafana";
2024-05-21 01:25:37 +00:00
cfg = config.services.skynet.grafana;
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;
};
};
ip = mkOption {
type = types.str;
default = cfg.host.ip;
};
port = mkOption {
type = types.port;
default = port;
2024-05-21 01:23:10 +00:00
};
};
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;
domain = "grafana.skynet.ie";
port = cfg.port;
addr = cfg.host.ip;
};
services.nginx.virtualHosts = {
"${name}.skynet.ie" = {
forceSSL = true;
useACMEHost = "skynet";
locations."/" = {
proxyPass = "https://localhost:${toString cfg.port}";
proxyWebsockets = true;
};
};
};
2024-05-21 01:23:10 +00:00
};
}