blob: 0a048279d38bc7f6a3e194d6c70737d445fb208a (
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
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
|
{ lib, ... }:
{
name = "qemu-vm-store";
meta.maintainers = with lib.maintainers; [ nikstur ];
defaults = {
nix.enable = true; # disabled by default. See all-tests.nix / tag(no-nix-by-default)
};
nodes = {
sharedWritable = {
virtualisation.writableStore = true;
};
sharedReadOnly = {
virtualisation.writableStore = false;
};
imageWritable = {
virtualisation.useNixStoreImage = true;
virtualisation.writableStore = true;
};
imageReadOnly = {
virtualisation.useNixStoreImage = true;
virtualisation.writableStore = false;
};
fullDisk = {
virtualisation.useBootLoader = true;
};
};
testScript = ''
build_derivation = """
nix-build --option substitute false -E 'derivation {
name = "t";
builder = "/bin/sh";
args = ["-c" "echo something > $out"];
system = builtins.currentSystem;
preferLocalBuild = true;
}'
"""
start_all()
with subtest("Nix Store is writable"):
sharedWritable.succeed(build_derivation)
imageWritable.succeed(build_derivation)
fullDisk.succeed(build_derivation)
with subtest("Nix Store is read only"):
sharedReadOnly.fail(build_derivation)
imageReadOnly.fail(build_derivation)
# Checking whether the fs type is virtiofs is just a proxy to test whether the
# Nix Store is shared.
with subtest("Nix store is shared from the host via virtiofs"):
sharedWritable.succeed("findmnt --kernel --type virtiofs /nix/.ro-store")
sharedReadOnly.succeed("findmnt --kernel --type virtiofs /nix/.ro-store")
with subtest("Nix store is not shared via virtiofs"):
imageWritable.fail("findmnt --kernel --type virtiofs /nix/.ro-store")
imageReadOnly.fail("findmnt --kernel --type virtiofs /nix/.ro-store")
with subtest("Nix store is not mounted separately"):
rootDevice = fullDisk.succeed("stat -c %d /")
nixStoreDevice = fullDisk.succeed("stat -c %d /nix/store")
assert rootDevice == nixStoreDevice, "Nix store is mounted separately from the root fs"
'';
}
|