···84 dnsmasq_conf=/etc/dnsmasq-conf.conf
85 dnsmasq_resolv=/etc/dnsmasq-resolv.conf
86 '';
87- };
00000008889 # The ‘ip-up’ target is started when we have IP connectivity. So
90 # services that depend on IP connectivity (like ntpd) should be
91 # pulled in by this target.
92 systemd.targets.ip-up.description = "Services Requiring IP Connectivity";
000000000000000000009394 };
95
···84 dnsmasq_conf=/etc/dnsmasq-conf.conf
85 dnsmasq_resolv=/etc/dnsmasq-resolv.conf
86 '';
87+88+ } // (optionalAttrs config.services.resolved.enable (
89+ if dnsmasqResolve then {
90+ "dnsmasq-resolv.conf".source = "/run/systemd/resolve/resolv.conf";
91+ } else {
92+ "resolv.conf".source = "/run/systemd/resolve/resolv.conf";
93+ }
94+ ));
9596 # The ‘ip-up’ target is started when we have IP connectivity. So
97 # services that depend on IP connectivity (like ntpd) should be
98 # pulled in by this target.
99 systemd.targets.ip-up.description = "Services Requiring IP Connectivity";
100+101+ # This is needed when /etc/resolv.conf is being overriden by networkd
102+ # and other configurations. If the file is destroyed by an environment
103+ # activation then it must be rebuilt so that applications which interface
104+ # with /etc/resolv.conf directly don't break.
105+ system.activationScripts.resolvconf = stringAfter [ "etc" "tmpfs" "var" ]
106+ ''
107+ # Systemd resolved controls its own resolv.conf
108+ rm -f /run/resolvconf/interfaces/systemd
109+ ${optionalString config.services.resolved.enable ''
110+ rm -rf /run/resolvconf/interfaces
111+ mkdir -p /run/resolvconf/interfaces
112+ ln -s /run/systemd/resolve/resolv.conf /run/resolvconf/interfaces/systemd
113+ ''}
114+115+ # Make sure resolv.conf is up to date if not managed by systemd
116+ ${optionalString (!config.services.resolved.enable) ''
117+ ${pkgs.openresolv}/bin/resolvconf -u
118+ ''}
119+ '';
120121 };
122
···141# Use /etc/resolv.conf supplied by systemd-nspawn, if applicable.
142if [ -n "@useHostResolvConf@" -a -e /etc/resolv.conf ]; then
143 cat /etc/resolv.conf | resolvconf -m 1000 -a host
144-else
145- touch /etc/resolv.conf
146fi
147148
···141# Use /etc/resolv.conf supplied by systemd-nspawn, if applicable.
142if [ -n "@useHostResolvConf@" -a -e /etc/resolv.conf ]; then
143 cat /etc/resolv.conf | resolvconf -m 1000 -a host
00144fi
145146