I haven’t poked through the source code much yet, but I did see some hard coded paths for binaries included in header definitions. Example here where we have:
#define BUSCTL "/usr/bin/busctl" #define RESOLVCONF "/usr/sbin/resolvconf" #define RESOLVECTL "/usr/bin/resolvectl" #define SYSTEMD_RESOLVE "/usr/bin/systemd-resolve"
Even though NixOS may have all of these binaries present and in the system environment path (I do in this case), none of the code utilizing these header definitions will work because of the path differences from FHS:
❯ for i in busctl resolvconf resolvectl systemd-resolve; do echo "Finding $i in path and resolved physical location" which $i readlink -e $(which $i) echo done Finding busctl path and physical location /run/current-system/sw/bin/busctl /nix/store/lwkp9z6w20yvavz6g87gfiglbp5xagb0-systemd-250.4/bin/busctl Finding resolvconf path and physical location /run/current-system/sw/bin/resolvconf /nix/store/lwkp9z6w20yvavz6g87gfiglbp5xagb0-systemd-250.4/bin/resolvectl Finding resolvectl path and physical location /run/current-system/sw/bin/resolvectl /nix/store/lwkp9z6w20yvavz6g87gfiglbp5xagb0-systemd-250.4/bin/resolvectl Finding systemd-resolve path and physical location /run/current-system/sw/bin/systemd-resolve /nix/store/lwkp9z6w20yvavz6g87gfiglbp5xagb0-systemd-250.4/bin/resolvectl
Perhaps required binaries could be found via $PATH search first, and then the use of hard-coded FHS paths as a fallback if needed?
I think the two functions is_systemd_resolved_primary_resolver and is_resolvconf_systemd_resolved don’t work for similar reasons, although in this case they are just static files, not binaries in the search path.
Just taking a quick look at the resolved paths on NixOS 22.05, we have two symlinks of indirection to the ziti tunneler expected hard-coded resolve path, so the function comparisons fail:
# With resolved enabled ❯ ls -la /etc/resolv.conf && echo && systemd-resolve --status | head lrwxrwxrwx 1 root root 23 Sep 30 19:00 /etc/resolv.conf -> /etc/static/resolv.conf Global Protocols: +LLMNR +mDNS -DNSOverTLS DNSSEC=allow-downgrade/unsupported resolv.conf mode: stub Current DNS Server: 126.96.36.199 DNS Servers: 188.8.131.52 192.168.1.1 Fallback DNS Servers: 184.108.40.206#cloudflare-dns.com 220.127.116.11#dns.google 18.104.22.168#cloudflare-dns.com 22.214.171.124#dns.google 2606:4700:4700::1111#cloudflare-dns.com 2001:4860:4860::8888#dns.google # ^^^ In this case it's 2 links of indirection to the expected hard-coded path: ❯ ls -la /etc/static/resolv.conf lrwxrwxrwx 1 root root 37 Dec 31 1969 /etc/static/resolv.conf -> /run/systemd/resolve/stub-resolv.conf # ------------------ # Without resolved enabled ❯ ls -la /etc/resolv.conf && systemd-resolve --status | head -rw-r--r-- 1 root root 117 Sep 30 19:04 /etc/resolv.conf Failed to get global data: Unit dbus-org.freedesktop.resolve1.service not found.