-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvmtest.nix
More file actions
77 lines (74 loc) · 2.23 KB
/
vmtest.nix
File metadata and controls
77 lines (74 loc) · 2.23 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
{ pkgs, exampleDepProxyHash }:
let
testsrc = pkgs.lib.sourceByRegex ./. [ "^[a-zA-Z0-9].*" ];
example_dep_proxy_data =
pkgs.runCommand "dgd-vmtest-proxy-data"
{
inherit (pkgs) go;
src = ./examples/dep;
outputHash = exampleDepProxyHash;
outputHashMode = "recursive";
}
''
cd $src
export GOTOOLCHAIN=local
export GOPATH=$TMPDIR/go
$go/bin/go mod download -x
cp -r $GOPATH/pkg/mod/cache/download $out
'';
in
pkgs.testers.runNixOSTest {
name = "dgd-vmtest";
nodes.machine =
{ pkgs, ... }:
{
# give more resources:
virtualisation.memorySize = 4096;
virtualisation.cores = 4;
virtualisation.diskSize = 10240;
# faster startup:
virtualisation.useNixStoreImage = true;
virtualisation.writableStore = true;
virtualisation.additionalPaths = [
# include nix sources.
# hack to avoid re-copying nixpkgs and source to store.
# pkgs must have been imported from a store path.
(builtins.storePath pkgs.path)
(builtins.storePath testsrc)
# include deps so that we can build without network:
pkgs.go
pkgs.stdenv
pkgs.stdenvNoCC
];
# fail fast if we missed something
nix.settings.substituters = pkgs.lib.mkForce [ ];
nix.settings.hashed-mirrors = pkgs.lib.mkForce [ ];
nix.settings.connect-timeout = 1;
# force proxy data into build env (simpler than using network)
nix.settings.sandbox-paths = [ example_dep_proxy_data ];
# use latest version and turn on dyndrv features
nix.package = pkgs.nixVersions.nix_2_32;
nix.settings = {
experimental-features = [
"nix-command"
"dynamic-derivations"
"ca-derivations"
"recursive-nix"
];
};
};
testScript = ''
machine.succeed("""
for dyn in true false; do
echo "====== building with dyn=$dyn"
nix-build \
${toString testsrc} \
--no-out-link \
-A testExamples \
--arg pkgs 'import ${toString pkgs.path} { }' \
--argstr goproxy file:///${example_dep_proxy_data} \
--arg useDynDrv $dyn
done
""")
'';
}