feat: several updates

This commit is contained in:
Xavier Morel
2025-12-09 14:35:20 +01:00
parent aec2e5bf63
commit a78704f30f
36 changed files with 826 additions and 150 deletions

View File

@@ -12,6 +12,7 @@ let
proxy_addr = ip "proxy";
domain_ext = config.globals.domains.external;
domain_int = config.globals.domains.internal;
json = pkgs.formats.json { };
in
{
environment.etc."alloy/logs-adguardhome.alloy".text =
@@ -41,13 +42,43 @@ in
}
'';
}).out;
environment.etc."AdGuardHome/data/leases.json".source = json.generate "leases.json" {
version = 1;
leases = (
lib.filter (x: x.mac != null) (
lib.mapAttrsToList (host: h: {
expires = "";
ip = tools.build_ip h.ip;
hostname = host;
mac = h.mac;
static = true;
}) config.globals.other_hosts
)
);
};
systemd.services.adguardhome.preStart = ''
cp /etc/AdGuardHome/data/leases.json /var/lib/AdGuardHome/data/leases.json
chown adguardhome:adguardhome /var/lib/AdGuardHome/data/leases.json
'';
services.adguardhome = {
enable = true;
allowDHCP = true;
host = "0.0.0.0";
port = 80;
openFirewall = true;
mutableSettings = true; # ??
settings = {
dhcp = {
enabled = true;
interface_name = "eth0";
dhcpv4 = {
gateway_ip = config.globals.gateway;
subnet_mask = config.globals.mask;
range_start = tools.build_ip 150;
range_end = tools.build_ip 199;
};
local_domain_name = lib.removePrefix "." config.globals.domains.internal;
};
http = {
address = "0.0.0.0:80";
session_ttl = "720h";
@@ -96,11 +127,13 @@ in
{
domain = "*${domain_ext}";
answer = proxy_addr;
enabled = true;
}
]
++ (lib.mapAttrsToList (d: id: {
domain = "${d}${domain_int}";
answer = "${ip d}";
enabled = true;
}) config.id);
};
};