Merge branch 'grafana' into 'main'
Add grafana See merge request compsoc1/skynet/nixos!32
This commit is contained in:
commit
50abdb90ab
2 changed files with 70 additions and 0 deletions
60
applications/grafana.nix
Normal file
60
applications/grafana.nix
Normal file
|
@ -0,0 +1,60 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
name = "grafana";
|
||||
cfg = config.services.skynet."${name}";
|
||||
port = 4444;
|
||||
in {
|
||||
imports = [
|
||||
./acme.nix
|
||||
./dns.nix
|
||||
];
|
||||
|
||||
options.services.skynet."${name}" = {
|
||||
enable = mkEnableOption "Grafana Server";
|
||||
|
||||
host = {
|
||||
ip = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
skynet_dns.records = [
|
||||
{
|
||||
record = "${name}";
|
||||
r_type = "CNAME";
|
||||
value = cfg.host.name;
|
||||
}
|
||||
];
|
||||
|
||||
skynet_acme.domains = [
|
||||
"${name}.skynet.ie"
|
||||
];
|
||||
|
||||
services.grafana = {
|
||||
enable = true;
|
||||
domain = "${name}.skynet.ie";
|
||||
port = port;
|
||||
addr = cfg.host.ip;
|
||||
};
|
||||
|
||||
services.nginx.virtualHosts = {
|
||||
"${name}.skynet.ie" = {
|
||||
forceSSL = true;
|
||||
useACMEHost = "skynet";
|
||||
locations."/" = {
|
||||
proxyPass = "http://localhost:${toString port}";
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -25,6 +25,7 @@ Notes:
|
|||
groups_trusted = map (x: "@${x}") groups;
|
||||
in {
|
||||
imports = [
|
||||
../applications/grafana.nix
|
||||
];
|
||||
|
||||
deployment = {
|
||||
|
@ -49,6 +50,15 @@ in {
|
|||
sudo_groups = groups;
|
||||
};
|
||||
|
||||
services.skynet.grafana = {
|
||||
enable = true;
|
||||
|
||||
host = {
|
||||
ip = ip_pub;
|
||||
name = name;
|
||||
};
|
||||
};
|
||||
|
||||
skynet_dns.records = [
|
||||
{
|
||||
record = name;
|
||||
|
|
Loading…
Reference in a new issue