Compare commits

..

View file

@ -342,47 +342,32 @@ in
# tuwunel hard-fails to boot if `/etc/resolv.conf` has no # tuwunel hard-fails to boot if `/etc/resolv.conf` has no
# `nameserver` line (`Failed to configure DNS resolver ... no # `nameserver` line (`Failed to configure DNS resolver ... no
# nameservers found in config` → exit 1). This declarative # nameservers found in config` → exit 1). This declarative
# nixos-container comes up with an EMPTY resolv.conf even with # nixos-container had it come up EMPTY (just `options edns0`)
# `networking.nameservers` set: the nixos-container default # even with `networking.nameservers` set: the nixos-container
# `useHostResolvConf = true` puts in-container resolvconf in # default `useHostResolvConf = true` puts in-container resolvconf
# host-tracking mode (ignores `networking.nameservers`, and never # in host-tracking mode, which ignores `networking.nameservers`
# gets the host file across the shared-netns boundary), so it # and never receives the host's resolv.conf across the
# regenerates an empty file and tuwunel dies at boot. # shared-netns boundary — so resolvconf regenerates an empty file
# and tuwunel dies at boot.
# #
# The earlier fix turned host-tracking off and trusted resolvconf # When the hive network module is on, turn off host-tracking so
# to honour `networking.nameservers` — but that's a RUNTIME # resolvconf honours `networking.nameservers`, pointing the
# resolvconf behaviour, not verifiable at eval time, and it STILL # resolver at the dnsmasq the network module runs at `bridgeIp`.
# came up empty in practice. So take resolvconf out of the
# loop entirely and write a STATIC `/etc/resolv.conf` from
# `bridgeIp` that nothing regenerates. Eval-proven: the generated
# `environment.etc."resolv.conf".text` is `nameserver <bridgeIp>`.
# This container always shares the host netns # This container always shares the host netns
# (`privateNetwork = false`), so it reaches `bridgeIp` regardless # (`privateNetwork = false`), so it reaches `bridgeIp` whether or
# of `isolateContainers`. Network module off → inherit the host's # not `isolateContainers` is set. With the network module off,
# resolv.conf. See `docs/network.md`. # inherit the host's resolv.conf (which carries the host
# resolver). See `docs/network.md`.
networking = lib.mkMerge [ networking = lib.mkMerge [
(lib.mkIf networkCfg.enable { (lib.mkIf networkCfg.enable {
# resolvconf is taken out of the loop entirely; the static
# `environment.etc."resolv.conf"` below is the sole source of
# the resolver file (no `nameservers` — nothing would read it).
useHostResolvConf = lib.mkForce false; useHostResolvConf = lib.mkForce false;
resolvconf.enable = lib.mkForce false; nameservers = [ networkCfg.bridgeIp ];
}) })
(lib.mkIf (!networkCfg.enable) { (lib.mkIf (!networkCfg.enable) {
useHostResolvConf = true; useHostResolvConf = true;
}) })
]; ];
# resolvconf is disabled above, so write the static resolver file
# explicitly — NixOS won't synthesise one from `nameservers` once
# resolvconf is off, and this is the file tuwunel parses at boot.
environment.etc = lib.mkIf networkCfg.enable {
"resolv.conf".text = ''
nameserver ${networkCfg.bridgeIp}
options edns0
'';
};
services.matrix-tuwunel = { services.matrix-tuwunel = {
enable = true; enable = true;
package = cfg.package; package = cfg.package;