summary refs log tree commit diff
path: root/nixos/tests/containers-custom-pkgs.nix
blob: 397a4a905e6d9676ed11c60c57e964bfe452a51f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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"
    )
  '';
})