-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
Expand file tree
/
Copy pathdriver-configuration.nix
More file actions
83 lines (81 loc) · 2.2 KB
/
driver-configuration.nix
File metadata and controls
83 lines (81 loc) · 2.2 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{
config,
lib,
hostPkgs,
...
}:
let
inherit (lib) types;
nodeConfigurationAttrs = lib.mkOption {
internal = true;
type = types.attrsOf (
types.submodule {
options = {
name = lib.mkOption {
internal = true;
type = types.str;
};
start_script = lib.mkOption {
internal = true;
type = types.path;
};
};
}
);
};
in
{
options = {
driverConfiguration = lib.mkOption {
description = "Configuration attribute set for test driver invocation";
internal = true;
type = types.submodule {
options = {
vms = nodeConfigurationAttrs;
containers = nodeConfigurationAttrs;
vlans = lib.mkOption {
internal = true;
type = types.listOf types.ints.unsigned;
};
global_timeout = lib.mkOption {
internal = true;
type = types.ints.unsigned;
};
enable_ssh_backdoor = lib.mkOption {
internal = true;
type = types.bool;
};
test_script = lib.mkOption {
internal = true;
type = types.path;
};
};
};
};
driverConfigurationFile = lib.mkOption {
internal = true;
type = types.path;
};
};
config = {
driverConfiguration = {
vms = lib.mapAttrs (name: value: {
inherit name;
start_script = lib.getExe value.system.build.vm;
}) config.nodes;
containers = lib.mapAttrs (name: value: {
inherit name;
start_script = lib.getExe value.system.build.nspawn;
}) config.containers;
vlans = lib.unique (
lib.concatMap (
m: (m.virtualisation.vlans ++ (lib.mapAttrsToList (_: v: v.vlan) m.virtualisation.interfaces))
) (lib.attrValues config.nodes ++ lib.attrValues config.containers)
);
global_timeout = config.globalTimeout;
test_script = hostPkgs.writeText "test-script" config.testScriptString;
enable_ssh_backdoor = config.sshBackdoor.enable;
};
driverConfigurationFile = hostPkgs.writers.writeJSON "driverConfiguration.json" config.driverConfiguration;
};
}