refactor(dnsmasq): system host info

This commit is contained in:
arcnmx 2024-03-28 13:07:26 -07:00
parent 86ac38cf2c
commit 6c88d99ae6
30 changed files with 841 additions and 288 deletions

View file

@ -1,13 +1,13 @@
{
lib,
config,
inputs,
options,
meta,
access,
...
}: let
inherit (lib.modules) mkIf mkBefore;
inherit (lib.modules) mkIf mkBefore mkOrder;
enableDns = !config.services.dnsmasq.enable && config.networking.hostName != "utsuho" && config.networking.hostName != "ct";
in {
imports = let
inherit (meta) nixos;
@ -15,7 +15,7 @@ in {
nixos.avahi
];
services.resolved.enable = true;
#services.resolved.enable = mkIf enableDns false;
systemd.services.avahi-daemon = mkIf (options ? proxmoxLXC && config.services.avahi.enable) {
serviceConfig.ExecStartPre = mkIf config.services.resolved.enable [
"+-${config.systemd.package}/bin/resolvectl mdns eth0 yes"
@ -26,9 +26,16 @@ in {
linkConfig.Multicast = true;
networkConfig.MulticastDNS = true;
};
networking.nameservers' = mkIf (!config.services.dnsmasq.enable && config.networking.hostName != "utsuho" && config.networking.hostName != "ct") (mkBefore [
networking.nameservers' = mkIf enableDns (mkBefore [
{ address = access.getAddressFor "utsuho" "lan"; }
]);
# prioritize our resolver over systemd-resolved!
system.nssDatabases.hosts = let
avahiResolverEnabled = config.services.avahi.enable && (config.services.avahi.nssmdns4 || config.services.avahi.nssmdns4);
in mkIf (enableDns && (config.services.resolved.enable || avahiResolverEnabled)) (mkOrder 499 ["dns"]);
services.resolved.extraConfig = mkIf enableDns ''
DNSStubListener=no
'';
boot.kernel.sysctl = {
# not sure how to get it to overlap with subgid/idmap...