1 # Test for NixOS' container support.
3 import ./make-test-python.nix ({ pkgs, ...} : {
4 name = "containers-hosts";
5 meta = with pkgs.stdenv.lib.maintainers; {
6 maintainers = [ montag451 ];
12 virtualisation.memorySize = 256;
13 virtualisation.vlans = [];
15 networking.bridges.br0.interfaces = [];
16 networking.interfaces.br0.ipv4.addresses = [
17 { address = "10.11.0.254"; prefixLength = 24; }
20 # Force /etc/hosts to be the only source for host name resolution
21 environment.etc."nsswitch.conf".text = lib.mkForce ''
27 privateNetwork = true;
28 localAddress = "10.10.0.1";
29 hostAddress = "10.10.0.254";
34 containers.netmask = {
36 privateNetwork = true;
38 localAddress = "10.11.0.1/24";
46 machine.wait_for_unit("default.target")
48 with subtest("Ping the containers using the entries added in /etc/hosts"):
49 for host in "simple.containers", "netmask.containers":
50 machine.succeed(f"ping -n -c 1 {host}")