diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..6ef7869 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,6 @@ +# Notes for running the tests + +The VM tests do Nix builds inside the VMs, so they have writable Nix stores. +Writable Nix stores in NixOS VM tests are, by default, tmpfs, but to speed up IO for the in-VM `nixos-rebuild`s, `./module-allow-rebuild-in-vm.nix` instead sets `virtualisation.writableStoreUseTmpfs = false;`, and allocates a much larger root filesystem for the VM. +Specifically, each VM test allocates 20 GiB. +If you are running low on disk space, disable `virtualisation.writableStoreUseTmpfs` in `./module-allow-rebuild-in-vm`. diff --git a/tests/module-allow-rebuild-in-vm.nix b/tests/module-allow-rebuild-in-vm.nix index 96280fe..fa14e9f 100644 --- a/tests/module-allow-rebuild-in-vm.nix +++ b/tests/module-allow-rebuild-in-vm.nix @@ -1,4 +1,4 @@ -{ name, config, ... }: +{ name, lib, config, ... }: { system.includeBuildDependencies = true; @@ -12,6 +12,12 @@ mountHostNixStore = true; installBootLoader = true; + # Moderately improves performance of `nixos-rebuild` inside the VM on my machine, + # (205.48 seconds to 186.42 seconds), but we have to allocate much more space. + writableStoreUseTmpfs = false; + # 20 GiB ought to be enough. + diskSize = lib.mkIf (!config.virtualisation.writableStoreUseTmpfs) (20 * 1024); + # With how much memory Nix eval uses, this is essentially required. memorySize = 8192; cores = 8;