about summary refs log tree commit diff
path: root/nixos/tests
diff options
context:
space:
mode:
authoradisbladis <adisbladis@gmail.com>2020-04-19 14:41:18 +0100
committeradisbladis <adisbladis@gmail.com>2020-04-20 07:33:46 +0100
commitab37d7e7ea6fa44bba109c30dd006037c93cbc52 (patch)
treed9d5e14be74b9454bac94b184df4313cc016fcb8 /nixos/tests
parent53c14c4e65cc5d58525fc9ec310d2e49d16d0283 (diff)
downloadnixlib-ab37d7e7ea6fa44bba109c30dd006037c93cbc52.tar
nixlib-ab37d7e7ea6fa44bba109c30dd006037c93cbc52.tar.gz
nixlib-ab37d7e7ea6fa44bba109c30dd006037c93cbc52.tar.bz2
nixlib-ab37d7e7ea6fa44bba109c30dd006037c93cbc52.tar.lz
nixlib-ab37d7e7ea6fa44bba109c30dd006037c93cbc52.tar.xz
nixlib-ab37d7e7ea6fa44bba109c30dd006037c93cbc52.tar.zst
nixlib-ab37d7e7ea6fa44bba109c30dd006037c93cbc52.zip
nixos-containers: Add support for custom nixpkgs argument
Diffstat (limited to 'nixos/tests')
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/containers-custom-pkgs.nix42
2 files changed, 43 insertions, 0 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index b0c9c7bc2258..30229a3a5b2f 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -53,6 +53,7 @@ in
   consul = handleTest ./consul.nix {};
   cockroachdb = handleTestOn ["x86_64-linux"] ./cockroachdb.nix {};
   containers-bridge = handleTest ./containers-bridge.nix {};
+  containers-custom-pkgs.nix = handleTest ./containers-custom-pkgs.nix {};
   containers-ephemeral = handleTest ./containers-ephemeral.nix {};
   containers-extra_veth = handleTest ./containers-extra_veth.nix {};
   containers-hosts = handleTest ./containers-hosts.nix {};
diff --git a/nixos/tests/containers-custom-pkgs.nix b/nixos/tests/containers-custom-pkgs.nix
new file mode 100644
index 000000000000..397a4a905e6d
--- /dev/null
+++ b/nixos/tests/containers-custom-pkgs.nix
@@ -0,0 +1,42 @@
+# Test for NixOS' container support.
+
+import ./make-test-python.nix ({ pkgs, lib, ...} : let
+
+  customPkgs = pkgs // {
+    hello = pkgs.hello.overrideAttrs(old: {
+      name = "custom-hello";
+    });
+  };
+
+in {
+  name = "containers-hosts";
+  meta = with lib.maintainers; {
+    maintainers = [ adisbladis ];
+  };
+
+  machine =
+    { ... }:
+    {
+      virtualisation.memorySize = 256;
+      virtualisation.vlans = [];
+
+      containers.simple = {
+        autoStart = true;
+        pkgs = customPkgs;
+        config = {pkgs, config, ... }: {
+          environment.systemPackages = [
+            pkgs.hello
+          ];
+        };
+      };
+
+    };
+
+  testScript = ''
+    start_all()
+    machine.wait_for_unit("default.target")
+    machine.succeed(
+        "test $(nixos-container run simple -- readlink -f /run/current-system/sw/bin/hello) = ${customPkgs.hello}/bin/hello"
+    )
+  '';
+})