1# Test for NixOS' container support.
2
3import ./make-test.nix ({ pkgs, ...} : {
4 name = "containers-hosts";
5 meta = with pkgs.stdenv.lib.maintainers; {
6 maintainers = [ montag451 ];
7 };
8
9 machine =
10 { config, pkgs, lib, ... }:
11 {
12 virtualisation.memorySize = 256;
13 virtualisation.vlans = [];
14
15 networking.bridges.br0.interfaces = [];
16 networking.interfaces.br0.ipv4.addresses = [
17 { address = "10.11.0.254"; prefixLength = 24; }
18 ];
19
20 # Force /etc/hosts to be the only source for host name resolution
21 environment.etc."nsswitch.conf".text = lib.mkForce ''
22 hosts: files
23 '';
24
25 containers.simple = {
26 autoStart = true;
27 privateNetwork = true;
28 localAddress = "10.10.0.1";
29 hostAddress = "10.10.0.254";
30
31 config = {};
32 };
33
34 containers.netmask = {
35 autoStart = true;
36 privateNetwork = true;
37 hostBridge = "br0";
38 localAddress = "10.11.0.1/24";
39
40 config = {};
41 };
42 };
43
44 testScript = ''
45 startAll;
46 $machine->waitForUnit("default.target");
47
48 # Ping the containers using the entries added in /etc/hosts
49 $machine->succeed("ping -n -c 1 simple.containers");
50 $machine->succeed("ping -n -c 1 netmask.containers");
51 '';
52})