From 40d73c5eb7c9beffea60d34161fd080881760c4a Mon Sep 17 00:00:00 2001 From: Jaka Hudoklin Date: Mon, 1 Dec 2014 17:20:18 +0100 Subject: [PATCH] nixos/docker: fix module, add simple test --- nixos/modules/virtualisation/docker.nix | 4 ++-- nixos/release.nix | 1 + nixos/tests/docker.nix | 24 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 nixos/tests/docker.nix diff --git a/nixos/modules/virtualisation/docker.nix b/nixos/modules/virtualisation/docker.nix index 9ae9624fd48..5be76b2682f 100644 --- a/nixos/modules/virtualisation/docker.nix +++ b/nixos/modules/virtualisation/docker.nix @@ -7,8 +7,8 @@ with lib; let cfg = config.virtualisation.docker; - pro = config.nix.proxy; - proxy_env = optionalAttrs (pro != "") { Environment = "\"http_proxy=${pro}\""; }; + pro = config.networking.proxy.default; + proxy_env = optionalAttrs (pro != null) { Environment = "\"http_proxy=${pro}\""; }; in diff --git a/nixos/release.nix b/nixos/release.nix index 05d64e14229..e0530276b64 100644 --- a/nixos/release.nix +++ b/nixos/release.nix @@ -239,6 +239,7 @@ in rec { tests.chromium = callTest tests/chromium.nix {}; tests.cjdns = callTest tests/cjdns.nix {}; tests.containers = callTest tests/containers.nix {}; + tests.docker = scrubDrv (import tests/docker.nix { system = "x86_64-linux"; }); tests.dockerRegistry = scrubDrv (import tests/docker-registry.nix { system = "x86_64-linux"; }); tests.etcd = scrubDrv (import tests/etcd.nix { system = "x86_64-linux"; }); tests.firefox = callTest tests/firefox.nix {}; diff --git a/nixos/tests/docker.nix b/nixos/tests/docker.nix new file mode 100644 index 00000000000..63c909ff294 --- /dev/null +++ b/nixos/tests/docker.nix @@ -0,0 +1,24 @@ +# This test runs docker and checks if simple container starts + +import ./make-test.nix { + name = "docker"; + + nodes = { + docker = + { config, pkgs, ... }: + { + virtualisation.docker.enable = true; + }; + }; + + testScript = '' + startAll; + + $docker->waitForUnit("docker.service"); + $docker->succeed("tar cv --files-from /dev/null | docker import - scratch"); + $docker->succeed("docker run -d --name=sleeping -v /nix/store:/nix/store -v /run/current-system/sw/bin:/bin scratch /bin/sleep 10"); + $docker->succeed("docker ps | grep sleeping"); + $docker->succeed("docker stop sleeping"); + ''; + +}