2023-02-23 22:42:03 +01:00
|
|
|
# Fast and lightweight DNS proxy as ad-blocker for local network
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.my.services.blocky;
|
|
|
|
domain = config.networking.domain;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.my.services.blocky = with lib; {
|
|
|
|
enable = mkEnableOption "Blocky DNS Server";
|
|
|
|
|
2023-06-04 21:08:37 +02:00
|
|
|
httpPort = mkOption {
|
|
|
|
type = types.port;
|
|
|
|
default = 8053;
|
|
|
|
example = 8080;
|
|
|
|
description = "port for requests";
|
|
|
|
};
|
|
|
|
|
2023-02-23 22:42:03 +01:00
|
|
|
settings = mkOption {
|
|
|
|
type = (pkgs.formats.json { }).type;
|
|
|
|
default = { };
|
2023-06-04 21:08:37 +02:00
|
|
|
example = literalExpression ''
|
|
|
|
{ ports.http = "8053" };
|
|
|
|
'';
|
2023-02-23 22:42:03 +01:00
|
|
|
description = ''
|
|
|
|
Override settings.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
services.blocky = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
settings = {
|
2023-06-04 21:08:37 +02:00
|
|
|
ports = {
|
|
|
|
tls = "853";
|
|
|
|
http = cfg.httpPort;
|
|
|
|
};
|
|
|
|
upstream = {
|
|
|
|
default = [
|
|
|
|
"dns2.digitalcourage.de2" # classic
|
|
|
|
"tcp-tls:dns3.digitalcourage.de" # DoT
|
|
|
|
"https://dns.digitale-gesellschaft.ch/dns-query" # DoH
|
|
|
|
];
|
|
|
|
};
|
|
|
|
prometheus.enable = config.services.prometheus.enable;
|
2023-02-23 22:42:03 +01:00
|
|
|
} // cfg.settings;
|
|
|
|
};
|
2023-06-04 21:08:37 +02:00
|
|
|
|
|
|
|
services.prometheus.scrapeConfigs = [
|
|
|
|
{
|
|
|
|
job_name = "blocky";
|
|
|
|
static_configs = [
|
|
|
|
{
|
|
|
|
targets = [ "127.0.0.1:${toString cfg.httpPort}" ];
|
|
|
|
labels = {
|
|
|
|
instance = config.networking.hostName;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
# untested
|
|
|
|
services.grafana.provision.dashboards.settings.providers = [
|
|
|
|
{
|
|
|
|
name = "Blocky";
|
|
|
|
options.path = pkgs.grafana-dashboards.blocky;
|
|
|
|
disableDeletion = true;
|
|
|
|
}
|
|
|
|
];
|
2023-02-23 22:42:03 +01:00
|
|
|
};
|
|
|
|
}
|