From f50a1bd99de9fff62d09887b81d3e1a00f2e69ee Mon Sep 17 00:00:00 2001 From: "Adam C. Stephens" Date: Fri, 22 Nov 2024 12:01:03 -0500 Subject: [PATCH] nixos/lxc/container: fix useDhcp with veth https://github.com/NixOS/nixpkgs/pull/347283 changed the default to exclude non-physical network Kind, but that unfortunately also includes `veth` which LXC uses for its network interfaces. Re-enable that functionality so users can use networkd with useDHCP. --- nixos/modules/virtualisation/lxc-container.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/nixos/modules/virtualisation/lxc-container.nix b/nixos/modules/virtualisation/lxc-container.nix index 42c323ee4503..ff7a4c11060b 100644 --- a/nixos/modules/virtualisation/lxc-container.nix +++ b/nixos/modules/virtualisation/lxc-container.nix @@ -31,6 +31,22 @@ ${config.nix.package.out}/bin/nix-env -p /nix/var/nix/profiles/system --set /run/current-system ''; + # supplement 99-ethernet-default-dhcp which excludes veth + systemd.network = lib.mkIf config.networking.useDHCP { + networks."99-lxc-veth-default-dhcp" = { + matchConfig = { + Type = "ether"; + Kind = "veth"; + Name = [ + "en*" + "eth*" + ]; + }; + DHCP = "yes"; + networkConfig.IPv6PrivacyExtensions = "kernel"; + }; + }; + system.build.tarball = pkgs.callPackage ../../lib/make-system-tarball.nix { extraArgs = "--owner=0";