about summary refs log tree commit diff
path: root/tests/make-test.nix
blob: 4534b991f151487664df43118d98479744d0bc8c (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
testFun:

{ system ? builtins.currentSystem
, nixpkgsPath ? import ../nixpkgs-path.nix
, ...
}@args: let

  lib = import "${nixpkgsPath}/lib";

  testLib = import "${nixpkgsPath}/nixos/lib/testing.nix" {
    inherit system;
  };

  pkgs = import nixpkgsPath { inherit system; };

  testArgs = if builtins.isFunction testFun then testFun (args // {
    pkgs = pkgs // {
      vuizvui = import ../pkgs { inherit pkgs; };
    };
    inherit nixpkgsPath;
  }) else testFun;

  nodes = testArgs.nodes or (if testArgs ? machine then {
    inherit (testArgs) machine;
  } else {});

  injectCommon = name: conf: {
    imports = [ conf ] ++ import ../modules/module-list.nix;
  };

  testArgsWithCommon = removeAttrs testArgs [ "machine" ] // {
    nodes = lib.mapAttrs injectCommon nodes;
  };

in testLib.makeTest testArgsWithCommon