From dcab169d6faaafa378428b761633fc1d651dc721 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Sat, 13 May 2017 20:23:41 -0400 Subject: Add new container, shape. --- config/container.nix | 9 +++++++++ machines/container-shape.nix | 12 ++++++++++++ release.nix | 1 + tests/container-shape.nix | 24 ++++++++++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 config/container.nix create mode 100644 machines/container-shape.nix create mode 100644 tests/container-shape.nix diff --git a/config/container.nix b/config/container.nix new file mode 100644 index 0000000..f4508f5 --- /dev/null +++ b/config/container.nix @@ -0,0 +1,9 @@ +{ config, lib, pkgs, ... }: +{ + boot.isContainer = true; + networking.firewall.allowedTCPPorts = [ 22 ]; + services.openssh.enable = lib.mkDefault true; + system.activationScripts.installInitScript = '' + ln -fs $systemConfig/init /init + ''; +} diff --git a/machines/container-shape.nix b/machines/container-shape.nix new file mode 100644 index 0000000..9890244 --- /dev/null +++ b/machines/container-shape.nix @@ -0,0 +1,12 @@ +{ config, lib, pkgs, ... }: +{ + imports = [ + ../config/container.nix + ../config/common.nix + ../config/users.nix + ]; + + networking = { + hostName = lib.mkForce "shape"; + }; +} diff --git a/release.nix b/release.nix index 6170387..cf7c777 100644 --- a/release.nix +++ b/release.nix @@ -7,6 +7,7 @@ tests = { common = import tests/common.nix; desktop = import tests/desktop.nix; + container-shape = import tests/container-shape.nix; }; } diff --git a/tests/container-shape.nix b/tests/container-shape.nix new file mode 100644 index 0000000..441694f --- /dev/null +++ b/tests/container-shape.nix @@ -0,0 +1,24 @@ +let + hostIp = "fc00::2"; + localIp = "fc00::1"; +in +import ( { pkgs, ... }: { + machine = + { config, pkgs, lib, ... }: { + containers.shape2 = { + privateNetwork = true; + hostAddress6 = hostIp; + localAddress6 = localIp; + config = import ../machines/container-shape.nix { + inherit config pkgs lib; + }; + }; + }; + + testScript = '' + $machine->waitForUnit("default.target"); + $machine->succeed("nixos-container list") =~ /shape2/ or die; + $machine->succeed("nixos-container start shape2"); + $machine->succeed("nixos-container run shape2 -- hostname") =~ /shape/ or die; + ''; +}) -- cgit v1.2.3