nixos/resolved: Allow upstream fallback override

The previous code did not apply any changes to the upstream defaults on being presented with an empty list.
This changes the code to use the above behaviour on a `null` value while an empty list is passed through as normal which yields a systemd configuration line with empty value which resets it to an empty value.

Signed-off-by: benaryorg <binary@benary.org>
This commit is contained in:
benaryorg 2023-12-08 16:00:42 +00:00
parent d384270823
commit 57846d0cae
No known key found for this signature in database
GPG key ID: E2F22C5EDF20119D

View file

@ -23,12 +23,13 @@ in
};
services.resolved.fallbackDns = mkOption {
default = [ ];
default = null;
example = [ "8.8.8.8" "2001:4860:4860::8844" ];
type = types.listOf types.str;
type = types.nullOr (types.listOf types.str);
description = lib.mdDoc ''
A list of IPv4 and IPv6 addresses to use as the fallback DNS servers.
If this option is empty, a compiled-in list of DNS servers is used instead.
If this option is null, a compiled-in list of DNS servers is used instead.
Setting this option to an empty list will override the built-in list to an empty list, disabling fallback.
'';
};
@ -134,7 +135,7 @@ in
[Resolve]
${optionalString (config.networking.nameservers != [])
"DNS=${concatStringsSep " " config.networking.nameservers}"}
${optionalString (cfg.fallbackDns != [])
${optionalString (cfg.fallbackDns != null)
"FallbackDNS=${concatStringsSep " " cfg.fallbackDns}"}
${optionalString (cfg.domains != [])
"Domains=${concatStringsSep " " cfg.domains}"}