summaryrefslogtreecommitdiffstats
path: root/nixos/tests/containers-custom-pkgs.nix
blob: 44236f809308c10b9a2259f592e25c6e4ab446cd (plain)
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
43
44
45
46
47
48
{ pkgs, lib, ... }:
let

  customPkgs = pkgs.appendOverlays [
    (self: super: {
      hello = super.hello.overrideAttrs (old: {
        name = "custom-hello";
      });
    })
  ];

in
{
  name = "containers-custom-pkgs";
  meta = {
    maintainers = with lib.maintainers; [ erikarvstedt ];
  };

  nodes.machine =
    { config, ... }:
    {
      assertions =
        let
          helloName = (builtins.head config.containers.test.config.system.extraDependencies).name;
        in
        [
          {
            assertion = helloName == "custom-hello";
            message = "Unexpected value: ${helloName}";
          }
        ];

      containers.test = {
        autoStart = true;
        config =
          { pkgs, config, ... }:
          {
            nixpkgs.pkgs = customPkgs;
            system.extraDependencies = [ pkgs.hello ];

            nix.enable = false; # disabled by default on the test's host. See all-tests.nix / tag(no-nix-by-default)
          };
      };
    };

  # This test only consists of evaluating the test machine
  testScript = "pass";
}