3 name = "qemu-vm-store";
5 meta.maintainers = with lib.maintainers; [ nikstur ];
9 virtualisation.writableStore = true;
13 virtualisation.writableStore = false;
17 virtualisation.useNixStoreImage = true;
18 virtualisation.writableStore = true;
22 virtualisation.useNixStoreImage = true;
23 virtualisation.writableStore = false;
27 virtualisation.useBootLoader = true;
32 build_derivation = """
33 nix-build --option substitute false -E 'derivation {
36 args = ["-c" "echo something > $out"];
37 system = builtins.currentSystem;
38 preferLocalBuild = true;
44 with subtest("Nix Store is writable"):
45 sharedWritable.succeed(build_derivation)
46 imageWritable.succeed(build_derivation)
47 fullDisk.succeed(build_derivation)
49 with subtest("Nix Store is read only"):
50 sharedReadOnly.fail(build_derivation)
51 imageReadOnly.fail(build_derivation)
53 # Checking whether the fs type is 9P is just a proxy to test whether the
54 # Nix Store is shared. If we switch to a different technology (e.g.
55 # virtiofs) for sharing, we need to adjust these tests.
57 with subtest("Nix store is shared from the host via 9P"):
58 sharedWritable.succeed("findmnt --kernel --type 9P /nix/.ro-store")
59 sharedReadOnly.succeed("findmnt --kernel --type 9P /nix/.ro-store")
61 with subtest("Nix store is not shared via 9P"):
62 imageWritable.fail("findmnt --kernel --type 9P /nix/.ro-store")
63 imageReadOnly.fail("findmnt --kernel --type 9P /nix/.ro-store")
65 with subtest("Nix store is not mounted separately"):
66 rootDevice = fullDisk.succeed("stat -c %d /")
67 nixStoreDevice = fullDisk.succeed("stat -c %d /nix/store")
68 assert rootDevice == nixStoreDevice, "Nix store is mounted separately from the root fs"