nixos/systemd-resolved: Re-indent

This commit is contained in:
Will Fancher 2024-04-07 20:32:41 -04:00
parent d3cda6aed3
commit 146bffe5aa

View File

@ -128,58 +128,61 @@ in
}; };
config = mkIf cfg.enable { config = mkMerge [
(mkIf cfg.enable {
assertions = [ assertions = [
{ assertion = !config.networking.useHostResolvConf; { assertion = !config.networking.useHostResolvConf;
message = "Using host resolv.conf is not supported with systemd-resolved"; message = "Using host resolv.conf is not supported with systemd-resolved";
} }
]; ];
users.users.systemd-resolve.group = "systemd-resolve"; users.users.systemd-resolve.group = "systemd-resolve";
# add resolve to nss hosts database if enabled and nscd enabled # add resolve to nss hosts database if enabled and nscd enabled
# system.nssModules is configured in nixos/modules/system/boot/systemd.nix # system.nssModules is configured in nixos/modules/system/boot/systemd.nix
# added with order 501 to allow modules to go before with mkBefore # added with order 501 to allow modules to go before with mkBefore
system.nssDatabases.hosts = (mkOrder 501 ["resolve [!UNAVAIL=return]"]); system.nssDatabases.hosts = (mkOrder 501 ["resolve [!UNAVAIL=return]"]);
systemd.additionalUpstreamSystemUnits = [ systemd.additionalUpstreamSystemUnits = [
"systemd-resolved.service" "systemd-resolved.service"
]; ];
systemd.services.systemd-resolved = { systemd.services.systemd-resolved = {
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
aliases = [ "dbus-org.freedesktop.resolve1.service" ]; aliases = [ "dbus-org.freedesktop.resolve1.service" ];
restartTriggers = [ config.environment.etc."systemd/resolved.conf".source ]; restartTriggers = [ config.environment.etc."systemd/resolved.conf".source ];
}; };
environment.etc = { environment.etc = {
"systemd/resolved.conf".text = '' "systemd/resolved.conf".text = ''
[Resolve] [Resolve]
${optionalString (config.networking.nameservers != []) ${optionalString (config.networking.nameservers != [])
"DNS=${concatStringsSep " " config.networking.nameservers}"} "DNS=${concatStringsSep " " config.networking.nameservers}"}
${optionalString (cfg.fallbackDns != null) ${optionalString (cfg.fallbackDns != null)
"FallbackDNS=${concatStringsSep " " cfg.fallbackDns}"} "FallbackDNS=${concatStringsSep " " cfg.fallbackDns}"}
${optionalString (cfg.domains != []) ${optionalString (cfg.domains != [])
"Domains=${concatStringsSep " " cfg.domains}"} "Domains=${concatStringsSep " " cfg.domains}"}
LLMNR=${cfg.llmnr} LLMNR=${cfg.llmnr}
DNSSEC=${cfg.dnssec} DNSSEC=${cfg.dnssec}
DNSOverTLS=${cfg.dnsovertls} DNSOverTLS=${cfg.dnsovertls}
${config.services.resolved.extraConfig} ${config.services.resolved.extraConfig}
''; '';
# symlink the dynamic stub resolver of resolv.conf as recommended by upstream: # symlink the dynamic stub resolver of resolv.conf as recommended by upstream:
# https://www.freedesktop.org/software/systemd/man/systemd-resolved.html#/etc/resolv.conf # https://www.freedesktop.org/software/systemd/man/systemd-resolved.html#/etc/resolv.conf
"resolv.conf".source = "/run/systemd/resolve/stub-resolv.conf"; "resolv.conf".source = "/run/systemd/resolve/stub-resolv.conf";
} // optionalAttrs dnsmasqResolve { } // optionalAttrs dnsmasqResolve {
"dnsmasq-resolv.conf".source = "/run/systemd/resolve/resolv.conf"; "dnsmasq-resolv.conf".source = "/run/systemd/resolve/resolv.conf";
}; };
# If networkmanager is enabled, ask it to interface with resolved. # If networkmanager is enabled, ask it to interface with resolved.
networking.networkmanager.dns = "systemd-resolved"; networking.networkmanager.dns = "systemd-resolved";
networking.resolvconf.package = pkgs.systemd; networking.resolvconf.package = pkgs.systemd;
}; })
];
} }