From c234e7b115ec00243982378eae27ee926923bd8e Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Mon, 24 Nov 2014 00:50:26 -0800 Subject: [PATCH] nixos/networking: Rebuild resolvconf during activation This is needed when /etc/resolv.conf is being overriden by networkd and other configurations. If the file is destroyed by an environment activation then it must be rebuilt so that applications which interface with /etc/resolv.conf directly don't break. --- nixos/modules/config/networking.nix | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/nixos/modules/config/networking.nix b/nixos/modules/config/networking.nix index 3ab75123110..711cbb2b70b 100644 --- a/nixos/modules/config/networking.nix +++ b/nixos/modules/config/networking.nix @@ -98,6 +98,24 @@ in # pulled in by this target. systemd.targets.ip-up.description = "Services Requiring IP Connectivity"; + # This is needed when /etc/resolv.conf is being overriden by networkd + # and other configurations. If the file is destroyed by an environment + # activation then it must be rebuilt so that applications which interface + # with /etc/resolv.conf directly don't break. + system.activationScripts.resolvconf = stringAfter [ "etc" "tmpfs" "var" ] + '' + # Systemd resolved controls its own resolv.conf + rm -f /run/resolvconf/interfaces/systemd + ${optionalString config.services.resolved.enable '' + rm -rf /run/resolvconf/interfaces + mkdir -p /run/resolvconf/interfaces + ln -s /run/systemd/resolve/resolv.conf /run/resolvconf/interfaces/systemd + ''} + + # Make sure resolv.conf is up to date + ${pkgs.openresolv}/bin/resolvconf -u + ''; + }; }