From 80acb28bee74d1d55109bc8511631dcbe21e04f1 Mon Sep 17 00:00:00 2001 From: talyz Date: Thu, 23 May 2019 13:25:40 +0200 Subject: [PATCH] networkmanager: Add rc-manager option Add an option to set the rc-manager parameter in NetworkManager.conf, which controls how NetworkManager handles resolv.conf. This sets the default rc-manager to "resolvconf", which solves #61490. It additionally allows the user to change rc-manager without interference from configuration activations. --- nixos/modules/config/networking.nix | 7 +++++-- .../services/networking/networkmanager.nix | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/nixos/modules/config/networking.nix b/nixos/modules/config/networking.nix index 25253cf02e1..8b352dad472 100644 --- a/nixos/modules/config/networking.nix +++ b/nixos/modules/config/networking.nix @@ -309,8 +309,11 @@ in ln -s /run/systemd/resolve/resolv.conf /run/resolvconf/interfaces/systemd ''} - # Make sure resolv.conf is up to date if not managed manually or by systemd - ${optionalString (!config.environment.etc?"resolv.conf") '' + # Make sure resolv.conf is up to date if not managed manually, by systemd or + # by NetworkManager + ${optionalString (!config.environment.etc?"resolv.conf" && + (cfg.networkmanager.enable -> + cfg.networkmanager.rc-manager == "resolvconf")) '' ${pkgs.openresolv}/bin/resolvconf -u ''} ''; diff --git a/nixos/modules/services/networking/networkmanager.nix b/nixos/modules/services/networking/networkmanager.nix index f1ba7dd4e4f..fa670b41116 100644 --- a/nixos/modules/services/networking/networkmanager.nix +++ b/nixos/modules/services/networking/networkmanager.nix @@ -17,6 +17,7 @@ let plugins=keyfile dhcp=${cfg.dhcp} dns=${cfg.dns} + rc-manager=${cfg.rc-manager} [keyfile] ${optionalString (cfg.unmanaged != []) @@ -283,6 +284,25 @@ in { ''; }; + rc-manager = mkOption { + type = types.enum [ "symlink" "file" "resolvconf" "netconfig" "unmanaged" "none" ]; + default = "resolvconf"; + description = '' + Set the resolv.conf management mode. + + + A description of these modes can be found in the main section of + + https://developer.gnome.org/NetworkManager/stable/NetworkManager.conf.html + + or in + + NetworkManager.conf + 5 + . + ''; + }; + dispatcherScripts = mkOption { type = types.listOf (types.submodule { options = {