From 5572de75a06ad051eeee8e6e74aa736ed0a58465 Mon Sep 17 00:00:00 2001 From: Bas van Dijk Date: Tue, 21 Nov 2017 08:41:41 +0100 Subject: [PATCH] containers: deny networkmanager from managing the ve-* and vb-* NICs Without this, when you've enabled networkmanager and start a nixos-container the container will briefly have its specified IP address but then networkmanager starts managing it causing the IP address to be dropped. --- nixos/modules/virtualisation/containers.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nixos/modules/virtualisation/containers.nix b/nixos/modules/virtualisation/containers.nix index e68bfd86060..12dbd54b306 100644 --- a/nixos/modules/virtualisation/containers.nix +++ b/nixos/modules/virtualisation/containers.nix @@ -726,6 +726,11 @@ in networking.dhcpcd.denyInterfaces = [ "ve-*" "vb-*" ]; + services.udev.extraRules = optionalString config.networking.networkmanager.enable '' + # Don't manage interfaces created by nixos-container. + ENV{INTERFACE}=="v[e,b]-*", ENV{NM_UNMANAGED}="1" + ''; + environment.systemPackages = [ pkgs.nixos-container ]; }); }