nixos: Add Netdata

This commit is contained in:
Jack O'Sullivan 2022-06-12 17:27:11 +01:00
parent f99eb399dc
commit c0ca7888aa
8 changed files with 64 additions and 2 deletions

View File

@ -57,6 +57,7 @@
boot.thin.enable = true;
dmeventd.enable = true;
};
netdata.enable = true;
};
environment.systemPackages = with pkgs; [

View File

@ -61,6 +61,7 @@
lvm = {
dmeventd.enable = true;
};
netdata.enable = true;
};
systemd.network = {

View File

@ -54,6 +54,8 @@
};
services = {
netdata.enable = true;
transmission = {
enable = true;
downloadDirPermissions = null;

View File

@ -31,7 +31,7 @@ in
tcp dport ${toString transmissionPeerPort} accept
iifname vpn return
tcp dport { 9091, 9117, 7878, 8989, 8096 } accept
tcp dport { 19999, 9091, 9117, 7878, 8989, 8096 } accept
return
}
chain input {

View File

@ -1,7 +1,7 @@
{ lib, pkgs, config, ... }:
let
inherit (builtins) mapAttrs toJSON;
inherit (lib) mkMerge mkDefault genAttrs flatten;
inherit (lib) mkMerge mkDefault genAttrs flatten concatStringsSep;
dualStackListen' = l: map (addr: l // { inherit addr; }) [ "0.0.0.0" "[::]" ];
dualStackListen = ll: flatten (map dualStackListen' ll);
@ -69,6 +69,37 @@ in
useACMEHost = lib.my.pubDomain;
};
"netdata-colony.${lib.my.pubDomain}" =
let
hosts = [ "vm" "fw" "ctr" "jackflix-ctr" ];
matchHosts = concatStringsSep "|" hosts;
in
mkMerge [
{
locations = {
"= /".return = "301 https://$host/colony/";
"~ /(?<behost>${matchHosts})$".return = "301 https://$host/$behost/";
"~ /(?<behost>${matchHosts})/(?<ndpath>.*)" = mkMerge [
{
proxyPass = "http://$behost.${config.networking.domain}:19999/$ndpath$is_args$args";
extraConfig = ''
proxy_pass_request_headers on;
proxy_set_header Connection "keep-alive";
proxy_store off;
gzip on;
gzip_proxied any;
gzip_types *;
'';
}
(ssoLoc "generic")
];
};
useACMEHost = lib.my.pubDomain;
}
(ssoServer "generic")
];
"pass.${lib.my.pubDomain}" =
let
upstream = "http://vaultwarden-ctr.${config.networking.domain}";

View File

@ -72,6 +72,10 @@
};
};
services = {
netdata.enable = true;
};
systemd.network = {
links = {
"10-vms" = {
@ -112,6 +116,7 @@
server.enable = true;
firewall = {
tcp.allowed = [ 19999 ];
trustedInterfaces = [ "vms" "ctrs" ];
};

View File

@ -128,6 +128,16 @@ in
permitRootLogin = mkDefault "no";
passwordAuthentication = mkDefault false;
};
netdata = {
config = {
global = {
"memory mode" = "dbengine";
"page cache size" = 32;
"dbengine multihost disk space" = 256;
};
};
};
};
}
(mkIf config.services.kmscon.enable {

View File

@ -280,6 +280,18 @@ in
}
];
})
(mkIf config.services.netdata.enable {
my.tmproot.persistence.config.directories = [
{
directory = "/var/lib/netdata";
inherit (config.services.netdata) user group;
}
{
directory = "/var/cache/netdata";
inherit (config.services.netdata) user group;
}
];
})
(persistSimpleSvc "transmission")
(persistSimpleSvc "jackett")
(persistSimpleSvc "radarr")