fix(matrix): write a static resolv.conf for tuwunel (eval-proven; #1500)
#1485's simplified fix turned off useHostResolvConf and trusted resolvconf to honour networking.nameservers, but that is a runtime resolvconf behaviour we couldn't verify at eval time — and it STILL came up with an empty /etc/resolv.conf in practice, so tuwunel kept failing the resolver init and matrix stayed down (#1500). Take resolvconf out of the loop entirely: resolvconf.enable = false plus an explicit environment.etc."resolv.conf" that writes nameserver <bridgeIp> statically. Nothing regenerates it out from under tuwunel. Eval-proven (unlike the prior variant): on a host with matrix+network on, the generated container environment.etc."resolv.conf".text is "nameserver <bridgeIp>\noptions edns0\n".
This commit is contained in:
parent
b5410d4613
commit
2efd9c4944
1 changed files with 27 additions and 14 deletions
|
|
@ -342,25 +342,28 @@ 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 had it come up EMPTY (just `options edns0`)
|
# nixos-container comes up with an EMPTY resolv.conf even with
|
||||||
# even with `networking.nameservers` set: the nixos-container
|
# `networking.nameservers` set: the nixos-container default
|
||||||
# default `useHostResolvConf = true` puts in-container resolvconf
|
# `useHostResolvConf = true` puts in-container resolvconf in
|
||||||
# in host-tracking mode, which ignores `networking.nameservers`
|
# host-tracking mode (ignores `networking.nameservers`, and never
|
||||||
# and never receives the host's resolv.conf across the
|
# gets the host file across the shared-netns boundary), so it
|
||||||
# shared-netns boundary — so resolvconf regenerates an empty file
|
# regenerates an empty file and tuwunel dies at boot.
|
||||||
# and tuwunel dies at boot.
|
|
||||||
#
|
#
|
||||||
# When the hive network module is on, turn off host-tracking so
|
# The earlier fix turned host-tracking off and trusted resolvconf
|
||||||
# resolvconf honours `networking.nameservers`, pointing the
|
# to honour `networking.nameservers` — but that's a RUNTIME
|
||||||
# resolver at the dnsmasq the network module runs at `bridgeIp`.
|
# resolvconf behaviour, not verifiable at eval time, and it STILL
|
||||||
|
# came up empty in practice (#1500). 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` whether or
|
# (`privateNetwork = false`), so it reaches `bridgeIp` regardless
|
||||||
# not `isolateContainers` is set. With the network module off,
|
# of `isolateContainers`. Network module off → inherit the host's
|
||||||
# inherit the host's resolv.conf (which carries the host
|
# resolv.conf. See `docs/network.md`.
|
||||||
# resolver). See `docs/network.md`.
|
|
||||||
networking = lib.mkMerge [
|
networking = lib.mkMerge [
|
||||||
(lib.mkIf networkCfg.enable {
|
(lib.mkIf networkCfg.enable {
|
||||||
useHostResolvConf = lib.mkForce false;
|
useHostResolvConf = lib.mkForce false;
|
||||||
|
resolvconf.enable = lib.mkForce false;
|
||||||
nameservers = [ networkCfg.bridgeIp ];
|
nameservers = [ networkCfg.bridgeIp ];
|
||||||
})
|
})
|
||||||
(lib.mkIf (!networkCfg.enable) {
|
(lib.mkIf (!networkCfg.enable) {
|
||||||
|
|
@ -368,6 +371,16 @@ in
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# 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;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue