diff options
author | aszlig <aszlig@redmoonstudios.org> | 2015-03-18 01:12:15 +0100 |
---|---|---|
committer | aszlig <aszlig@redmoonstudios.org> | 2015-03-18 01:12:15 +0100 |
commit | 692b0772223074133c5fe74d84ea727fb00499e3 (patch) | |
tree | d3d20d087665377ef0f7622e66bd6557fbaebcc9 /labernix/tests | |
parent | 0182c32769f18926489847bb21636e7b394b5b30 (diff) | |
parent | 6b857eebbafba660cc57b19bd11f6484c91f8fd7 (diff) |
Subtree-merge labernix into vuizvui.
This is the first step of generalizing the configurations into a big repository where people can track their NixOS configurations and write modules. In the next few steps I'm going to gradually refactor everything in labernix/ into the main tree and factor out personal stuff into separate namespaces. Also, this will involve a license change from APACHE-2.0 to GPL-3.0.
Diffstat (limited to 'labernix/tests')
-rw-r--r-- | labernix/tests/heinrich.nix | 51 | ||||
-rw-r--r-- | labernix/tests/make-test.nix | 28 |
2 files changed, 79 insertions, 0 deletions
diff --git a/labernix/tests/heinrich.nix b/labernix/tests/heinrich.nix new file mode 100644 index 00000000..c524835e --- /dev/null +++ b/labernix/tests/heinrich.nix @@ -0,0 +1,51 @@ +import ./make-test.nix { + name = "heinrich"; + + nodes = let + common = { lib, ... }: { + networking.useNetworkd = true; + systemd.network.netdevs."40-eth0".netdevConfig = { + Name = "eth0"; + Kind = "dummy"; + }; + }; + in { + heinrich = { + imports = [ common ../machines/heinrich.nix ]; + virtualisation.vlans = [ 1 8 14 ]; + heinrich.internalInterface = "eth1"; + heinrich.externalInterface = "eth2"; + }; + hotelturm = { lib, ... }: { + imports = [ common ]; + virtualisation.vlans = [ 8 ]; + networking.useDHCP = false; + networking.interfaces.eth1.ip4 = lib.singleton { + address = "10.11.77.16"; + prefixLength = 24; + }; + }; + moritz = { lib, ... }: { + imports = [ common ]; + virtualisation.vlans = [ 14 ]; + networking.useDHCP = false; + networking.interfaces.eth1.ip4 = lib.singleton { + address = "192.168.0.1"; + prefixLength = 24; + }; + }; + client = { + imports = [ common ]; + virtualisation.vlans = [ 1 ]; + }; + }; + + testScript = '' + startAll; + $heinrich->waitForUnit("dnsmasq.service"); + $client->waitForUnit("network-interfaces.target"); + $client->waitForUnit("network.target"); + + $client->succeed("ip addr >&2"); + ''; +} diff --git a/labernix/tests/make-test.nix b/labernix/tests/make-test.nix new file mode 100644 index 00000000..10381afd --- /dev/null +++ b/labernix/tests/make-test.nix @@ -0,0 +1,28 @@ +f: { system ? builtins.currentSystem, ... } @ args: let + lib = import <nixpkgs/lib>; + + testLib = import <nixpkgs/nixos/lib/testing.nix> { + inherit system; + }; + + pkgs = import <nixpkgs> { inherit system; }; + + testArgs = if builtins.isFunction f then f (args // { + pkgs = pkgs // { + labernix = import ../pkgs { inherit pkgs; }; + }; + }) else f; + + nodes = testArgs.nodes or (if testArgs ? machine then { + inherit (testArgs) machine; + } else {}); + + injectCommon = name: conf: { + imports = [ ../common.nix conf ]; + }; + + testArgsWithCommon = removeAttrs testArgs [ "machine" ] // { + nodes = lib.mapAttrs injectCommon nodes; + }; + +in testLib.makeTest testArgsWithCommon |