Loading
nixos-containers: allow hard-coding container veth MAC address
When using a NixOS container with `privateNetwork = true;` (i.e., a veth network device), it automatically gets assigned a random, locally administered unicast MAC address. While this is fine for many purposes, when attaching this container to a larger Layer 2 network where it interacts with other services, like an external DHCP server or IPv6 gateway sending out router advertisements, the MAC address of the container matters. This commit thus adds a `macAddress` option to containers. If set, this MAC address will be assigned to the container-side of the `veth` interface very early during container boot (before executing the stage 2 init script). This is crucial to ensure that no services run in the container using the prior, random MAC automatically assigned to the `veth` device. Otherweise, I've had problems using systemd units or the activation scripts to set the address early enough during container boot to use it, for example, for IPv6 SLAAC address assignment.